From 08636e2d06b460fcaab3d79e2851d8095eb54f02 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:07:42 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#32) --- SECURITY.md | 2 +- .../client/okhttp/BraintrustOkHttpClient.kt | 63 +- .../okhttp/BraintrustOkHttpClientAsync.kt | 63 +- .../api/client/okhttp/OkHttpClient.kt | 45 +- .../api/client/BraintrustClient.kt | 19 + .../api/client/BraintrustClientAsync.kt | 19 + .../api/client/BraintrustClientAsyncImpl.kt | 44 +- .../api/client/BraintrustClientImpl.kt | 24 +- .../api/core/BaseDeserializer.kt | 20 +- .../braintrustdata/api/core/ClientOptions.kt | 128 +- .../com/braintrustdata/api/core/Properties.kt | 11 +- .../braintrustdata/api/core/RequestOptions.kt | 4 +- .../com/braintrustdata/api/core/Utils.kt | 10 +- .../com/braintrustdata/api/core/Values.kt | 139 +- .../api/core/http/BinaryResponseContent.kt | 1 + .../api/core/http/HttpClient.kt | 2 +- .../api/core/http/HttpRequest.kt | 3 +- .../api/core/http/HttpRequestBody.kt | 7 +- .../api/core/http/RetryingHttpClient.kt | 128 +- .../api/errors/BadRequestException.kt | 6 +- .../api/errors/BraintrustError.kt | 31 +- .../api/errors/BraintrustException.kt | 3 +- .../errors/BraintrustInvalidDataException.kt | 3 +- .../api/errors/BraintrustIoException.kt | 3 +- .../api/errors/BraintrustServiceException.kt | 12 +- .../api/errors/InternalServerException.kt | 8 +- .../api/errors/NotFoundException.kt | 6 +- .../api/errors/PermissionDeniedException.kt | 6 +- .../api/errors/RateLimitException.kt | 6 +- .../api/errors/UnauthorizedException.kt | 6 +- .../errors/UnexpectedStatusCodeException.kt | 8 +- .../errors/UnprocessableEntityException.kt | 6 +- .../com/braintrustdata/api/models/Acl.kt | 566 +- .../api/models/AclCreateParams.kt | 626 ++- .../api/models/AclDeleteParams.kt | 119 +- .../braintrustdata/api/models/AclListPage.kt | 143 +- .../api/models/AclListPageAsync.kt | 149 +- .../api/models/AclListParams.kt | 384 +- .../api/models/AclObjectType.kt | 120 - .../api/models/AclRetrieveParams.kt | 98 +- .../com/braintrustdata/api/models/ApiKey.kt | 183 +- .../api/models/ApiKeyCreateParams.kt | 274 - .../api/models/ApiKeyCreateResponse.kt | 236 - .../api/models/ApiKeyDeleteParams.kt | 153 - .../api/models/ApiKeyListPage.kt | 173 - .../api/models/ApiKeyListPageAsync.kt | 175 - .../api/models/ApiKeyListParams.kt | 358 -- .../api/models/ApiKeyResourceCreateParams.kt | 219 +- .../api/models/ApiKeyResourceDeleteParams.kt | 119 +- .../api/models/ApiKeyResourceListPage.kt | 153 +- .../api/models/ApiKeyResourceListPageAsync.kt | 159 +- .../api/models/ApiKeyResourceListParams.kt | 307 +- .../models/ApiKeyResourceRetrieveParams.kt | 98 +- .../api/models/ApiKeyRetrieveParams.kt | 149 - .../braintrustdata/api/models/CreateAcl.kt | 611 --- .../api/models/CreateApiKeyOutput.kt | 201 +- .../api/models/CreateDataset.kt | 157 - .../api/models/CreateExperiment.kt | 422 -- .../api/models/CreateFunction.kt | 1619 ------ .../braintrustdata/api/models/CreateGroup.kt | 239 - .../api/models/CreateProject.kt | 152 - .../api/models/CreateProjectScore.kt | 599 --- .../api/models/CreateProjectTag.kt | 178 - .../braintrustdata/api/models/CreatePrompt.kt | 220 - .../braintrustdata/api/models/CreateRole.kt | 596 --- .../braintrustdata/api/models/CreateView.kt | 470 -- .../api/models/CrossObjectInsertRequest.kt | 375 -- .../api/models/CrossObjectInsertResponse.kt | 196 +- .../braintrustdata/api/models/DataSummary.kt | 72 +- .../com/braintrustdata/api/models/Dataset.kt | 243 +- .../api/models/DatasetCreateParams.kt | 233 +- .../api/models/DatasetDeleteParams.kt | 119 +- .../braintrustdata/api/models/DatasetEvent.kt | 440 +- .../api/models/DatasetFeedbackParams.kt | 178 +- .../api/models/DatasetFetchParams.kt | 225 +- .../api/models/DatasetFetchPostParams.kt | 567 +- .../api/models/DatasetFetchPostResponse.kt | 624 --- .../api/models/DatasetFetchResponse.kt | 624 --- .../api/models/DatasetInsertParams.kt | 300 +- .../api/models/DatasetInsertResponse.kt | 121 - .../api/models/DatasetListPage.kt | 143 +- .../api/models/DatasetListPageAsync.kt | 149 +- .../api/models/DatasetListParams.kt | 339 +- .../api/models/DatasetRetrieveParams.kt | 98 +- .../api/models/DatasetSummarizeParams.kt | 126 +- .../api/models/DatasetSummarizeResponse.kt | 298 -- .../api/models/DatasetUpdateParams.kt | 273 +- .../braintrustdata/api/models/DeleteView.kt | 250 - .../braintrustdata/api/models/Experiment.kt | 395 +- .../api/models/ExperimentCreateParams.kt | 506 +- .../api/models/ExperimentDeleteParams.kt | 119 +- .../api/models/ExperimentEvent.kt | 1251 +++-- .../api/models/ExperimentFeedbackParams.kt | 174 +- .../api/models/ExperimentFetchParams.kt | 225 +- .../api/models/ExperimentFetchPostParams.kt | 567 +- .../api/models/ExperimentFetchPostResponse.kt | 1601 ------ .../api/models/ExperimentFetchResponse.kt | 1601 ------ .../api/models/ExperimentInsertParams.kt | 311 +- .../api/models/ExperimentInsertResponse.kt | 121 - .../api/models/ExperimentListPage.kt | 147 +- .../api/models/ExperimentListPageAsync.kt | 153 +- .../api/models/ExperimentListParams.kt | 339 +- .../api/models/ExperimentRetrieveParams.kt | 98 +- .../api/models/ExperimentSummarizeParams.kt | 145 +- .../api/models/ExperimentSummarizeResponse.kt | 396 -- .../api/models/ExperimentUpdateParams.kt | 445 +- .../api/models/FeedbackDatasetEventRequest.kt | 113 - .../api/models/FeedbackDatasetItem.kt | 253 +- .../models/FeedbackExperimentEventRequest.kt | 113 - .../api/models/FeedbackExperimentItem.kt | 345 +- .../models/FeedbackProjectLogsEventRequest.kt | 114 - .../api/models/FeedbackProjectLogsItem.kt | 345 +- .../api/models/FeedbackResponseSchema.kt | 114 +- .../api/models/FetchDatasetEventsResponse.kt | 123 +- .../api/models/FetchEventsRequest.kt | 418 -- .../models/FetchExperimentEventsResponse.kt | 123 +- .../models/FetchProjectLogsEventsResponse.kt | 123 +- .../com/braintrustdata/api/models/Function.kt | 2264 ++++---- .../api/models/FunctionCreateParams.kt | 2242 ++++---- .../api/models/FunctionDeleteParams.kt | 119 +- .../api/models/FunctionListPage.kt | 143 +- .../api/models/FunctionListPageAsync.kt | 153 +- .../api/models/FunctionListParams.kt | 375 +- .../api/models/FunctionReplaceParams.kt | 2242 ++++---- .../api/models/FunctionRetrieveParams.kt | 98 +- .../api/models/FunctionUpdateParams.kt | 1980 ++++--- .../com/braintrustdata/api/models/Group.kt | 248 +- .../api/models/GroupCreateParams.kt | 321 +- .../api/models/GroupDeleteParams.kt | 119 +- .../api/models/GroupListPage.kt | 143 +- .../api/models/GroupListPageAsync.kt | 149 +- .../api/models/GroupListParams.kt | 307 +- .../api/models/GroupReplaceParams.kt | 321 +- .../api/models/GroupRetrieveParams.kt | 98 +- .../api/models/GroupUpdateParams.kt | 300 +- .../com/braintrustdata/api/models/Ids.kt | 126 - .../api/models/InsertDatasetEvent.kt | 146 - .../api/models/InsertDatasetEventMerge.kt | 512 +- .../api/models/InsertDatasetEventReplace.kt | 508 +- .../api/models/InsertDatasetEventRequest.kt | 252 - .../api/models/InsertEventsResponse.kt | 92 +- .../api/models/InsertExperimentEvent.kt | 151 - .../api/models/InsertExperimentEventMerge.kt | 1293 ++--- .../models/InsertExperimentEventReplace.kt | 1289 ++--- .../models/InsertExperimentEventRequest.kt | 259 - .../api/models/InsertProjectLogsEvent.kt | 153 - .../api/models/InsertProjectLogsEventMerge.kt | 1243 +++-- .../models/InsertProjectLogsEventReplace.kt | 1239 +++-- .../models/InsertProjectLogsEventRequest.kt | 262 - .../api/models/MetricSummary.kt | 182 +- .../braintrustdata/api/models/OrgSecret.kt | 221 +- .../api/models/OrgSecretCreateParams.kt | 345 +- .../api/models/OrgSecretDeleteParams.kt | 119 +- .../api/models/OrgSecretListPage.kt | 147 +- .../api/models/OrgSecretListPageAsync.kt | 153 +- .../api/models/OrgSecretListParams.kt | 411 +- .../api/models/OrgSecretReplaceParams.kt | 345 +- .../api/models/OrgSecretRetrieveParams.kt | 98 +- .../api/models/OrgSecretUpdateParams.kt | 304 +- .../braintrustdata/api/models/Organization.kt | 197 +- .../api/models/OrganizationDeleteParams.kt | 119 +- .../api/models/OrganizationListPage.kt | 153 +- .../api/models/OrganizationListPageAsync.kt | 159 +- .../api/models/OrganizationListParams.kt | 291 +- .../models/OrganizationMemberUpdateParams.kt | 514 +- .../OrganizationMemberUpdateResponse.kt | 169 +- .../api/models/OrganizationRetrieveParams.kt | 98 +- .../api/models/OrganizationUpdateParams.kt | 306 +- .../braintrustdata/api/models/PatchDataset.kt | 229 - .../api/models/PatchExperiment.kt | 364 -- .../api/models/PatchFunction.kt | 1673 ------ .../braintrustdata/api/models/PatchGroup.kt | 236 - .../api/models/PatchOrganization.kt | 185 - .../api/models/PatchOrganizationMembers.kt | 550 -- .../braintrustdata/api/models/PatchProject.kt | 246 - .../api/models/PatchProjectScore.kt | 578 -- .../api/models/PatchProjectTag.kt | 157 - .../braintrustdata/api/models/PatchPrompt.kt | 178 - .../braintrustdata/api/models/PatchRole.kt | 949 ---- .../braintrustdata/api/models/PatchView.kt | 448 -- .../api/models/PathLookupFilter.kt | 225 +- .../com/braintrustdata/api/models/Project.kt | 238 +- .../api/models/ProjectCreateParams.kt | 219 +- .../api/models/ProjectDeleteParams.kt | 119 +- .../api/models/ProjectListPage.kt | 143 +- .../api/models/ProjectListPageAsync.kt | 149 +- .../api/models/ProjectListParams.kt | 307 +- .../api/models/ProjectLogFeedbackParams.kt | 174 +- .../api/models/ProjectLogFetchParams.kt | 225 +- .../api/models/ProjectLogFetchPostParams.kt | 567 +- .../api/models/ProjectLogFetchPostResponse.kt | 1628 ------ .../api/models/ProjectLogFetchResponse.kt | 1628 ------ .../api/models/ProjectLogInsertParams.kt | 316 +- .../api/models/ProjectLogInsertResponse.kt | 121 - .../api/models/ProjectLogsEvent.kt | 1261 +++-- .../api/models/ProjectRetrieveParams.kt | 98 +- .../braintrustdata/api/models/ProjectScore.kt | 1161 ++--- .../api/models/ProjectScoreCategory.kt | 107 +- .../api/models/ProjectScoreCreateParams.kt | 583 +-- .../api/models/ProjectScoreDeleteParams.kt | 119 +- .../api/models/ProjectScoreListPage.kt | 153 +- .../api/models/ProjectScoreListPageAsync.kt | 159 +- .../api/models/ProjectScoreListParams.kt | 579 ++- .../api/models/ProjectScoreReplaceParams.kt | 583 +-- .../api/models/ProjectScoreRetrieveParams.kt | 98 +- .../api/models/ProjectScoreUpdateParams.kt | 568 +- .../braintrustdata/api/models/ProjectTag.kt | 205 +- .../api/models/ProjectTagCreateParams.kt | 267 +- .../api/models/ProjectTagDeleteParams.kt | 119 +- .../api/models/ProjectTagListPage.kt | 147 +- .../api/models/ProjectTagListPageAsync.kt | 153 +- .../api/models/ProjectTagListParams.kt | 339 +- .../api/models/ProjectTagReplaceParams.kt | 267 +- .../api/models/ProjectTagRetrieveParams.kt | 98 +- .../api/models/ProjectTagUpdateParams.kt | 252 +- .../api/models/ProjectUpdateParams.kt | 271 +- .../com/braintrustdata/api/models/Prompt.kt | 438 +- .../api/models/PromptCreateParams.kt | 401 +- .../braintrustdata/api/models/PromptData.kt | 4627 ++++++++--------- .../api/models/PromptDeleteParams.kt | 119 +- .../api/models/PromptListPage.kt | 143 +- .../api/models/PromptListPageAsync.kt | 149 +- .../api/models/PromptListParams.kt | 375 +- .../api/models/PromptReplaceParams.kt | 401 +- .../api/models/PromptRetrieveParams.kt | 98 +- .../api/models/PromptUpdateParams.kt | 311 +- .../com/braintrustdata/api/models/RepoInfo.kt | 248 +- .../com/braintrustdata/api/models/Role.kt | 500 +- .../api/models/RoleCreateParams.kt | 529 +- .../api/models/RoleDeleteParams.kt | 119 +- .../braintrustdata/api/models/RoleListPage.kt | 143 +- .../api/models/RoleListPageAsync.kt | 149 +- .../api/models/RoleListParams.kt | 307 +- .../api/models/RoleReplaceParams.kt | 529 +- .../api/models/RoleRetrieveParams.kt | 98 +- .../api/models/RoleUpdateParams.kt | 733 +-- .../braintrustdata/api/models/ScoreSummary.kt | 164 +- .../api/models/SummarizeDatasetResponse.kt | 160 +- .../api/models/SummarizeExperimentResponse.kt | 238 +- .../api/models/TopLevelHelloWorldParams.kt | 66 +- .../com/braintrustdata/api/models/User.kt | 183 +- .../braintrustdata/api/models/UserEmail.kt | 130 - .../api/models/UserFamilyName.kt | 132 - .../api/models/UserGivenName.kt | 132 - .../braintrustdata/api/models/UserListPage.kt | 143 +- .../api/models/UserListPageAsync.kt | 149 +- .../api/models/UserListParams.kt | 665 +-- .../api/models/UserRetrieveParams.kt | 98 +- .../com/braintrustdata/api/models/View.kt | 400 +- .../api/models/ViewCreateParams.kt | 524 +- .../com/braintrustdata/api/models/ViewData.kt | 69 +- .../api/models/ViewDataSearch.kt | 146 +- .../api/models/ViewDeleteParams.kt | 300 +- .../braintrustdata/api/models/ViewListPage.kt | 143 +- .../api/models/ViewListPageAsync.kt | 149 +- .../api/models/ViewListParams.kt | 482 +- .../braintrustdata/api/models/ViewOptions.kt | 168 +- .../api/models/ViewReplaceParams.kt | 524 +- .../api/models/ViewRetrieveParams.kt | 218 +- .../com/braintrustdata/api/models/ViewType.kt | 102 - .../api/models/ViewUpdateParams.kt | 514 +- .../braintrustdata/api/services/Handlers.kt | 15 +- .../api/services/HttpRequestBodies.kt | 35 +- .../api/services/async/AclServiceAsync.kt | 62 +- .../api/services/async/AclServiceAsyncImpl.kt | 224 +- .../async/ApiKeyResourceServiceAsync.kt | 58 +- .../async/ApiKeyResourceServiceAsyncImpl.kt | 235 +- .../api/services/async/ApiKeyServiceAsync.kt | 47 - .../services/async/ApiKeyServiceAsyncImpl.kt | 151 - .../api/services/async/DatasetServiceAsync.kt | 103 +- .../services/async/DatasetServiceAsyncImpl.kt | 531 +- .../services/async/ExperimentServiceAsync.kt | 107 +- .../async/ExperimentServiceAsyncImpl.kt | 535 +- .../services/async/FunctionServiceAsync.kt | 81 +- .../async/FunctionServiceAsyncImpl.kt | 342 +- .../api/services/async/GroupServiceAsync.kt | 83 +- .../services/async/GroupServiceAsyncImpl.kt | 329 +- .../services/async/OrgSecretServiceAsync.kt | 84 +- .../async/OrgSecretServiceAsyncImpl.kt | 345 +- .../async/OrganizationServiceAsync.kt | 65 +- .../async/OrganizationServiceAsyncImpl.kt | 245 +- .../async/ProjectScoreServiceAsync.kt | 86 +- .../async/ProjectScoreServiceAsyncImpl.kt | 347 +- .../api/services/async/ProjectServiceAsync.kt | 70 +- .../services/async/ProjectServiceAsyncImpl.kt | 292 +- .../services/async/ProjectTagServiceAsync.kt | 85 +- .../async/ProjectTagServiceAsyncImpl.kt | 346 +- .../api/services/async/PromptServiceAsync.kt | 84 +- .../services/async/PromptServiceAsyncImpl.kt | 345 +- .../api/services/async/RoleServiceAsync.kt | 83 +- .../services/async/RoleServiceAsyncImpl.kt | 324 +- .../services/async/TopLevelServiceAsync.kt | 44 +- .../async/TopLevelServiceAsyncImpl.kt | 73 +- .../api/services/async/UserServiceAsync.kt | 48 +- .../services/async/UserServiceAsyncImpl.kt | 138 +- .../api/services/async/ViewServiceAsync.kt | 83 +- .../services/async/ViewServiceAsyncImpl.kt | 322 +- .../async/organization/MemberServiceAsync.kt | 39 +- .../organization/MemberServiceAsyncImpl.kt | 82 +- .../async/organizations/MemberServiceAsync.kt | 18 - .../organizations/MemberServiceAsyncImpl.kt | 54 - .../services/async/project/LogServiceAsync.kt | 62 +- .../async/project/LogServiceAsyncImpl.kt | 236 +- .../async/projects/LogServiceAsync.kt | 46 - .../async/projects/LogServiceAsyncImpl.kt | 145 - .../api/services/blocking/AclService.kt | 52 +- .../api/services/blocking/AclServiceImpl.kt | 218 +- .../blocking/ApiKeyResourceService.kt | 58 +- .../blocking/ApiKeyResourceServiceImpl.kt | 235 +- .../api/services/blocking/ApiKeyService.kt | 47 - .../services/blocking/ApiKeyServiceImpl.kt | 142 - .../api/services/blocking/DatasetService.kt | 103 +- .../services/blocking/DatasetServiceImpl.kt | 506 +- .../services/blocking/ExperimentService.kt | 107 +- .../blocking/ExperimentServiceImpl.kt | 535 +- .../api/services/blocking/FunctionService.kt | 81 +- .../services/blocking/FunctionServiceImpl.kt | 322 +- .../api/services/blocking/GroupService.kt | 83 +- .../api/services/blocking/GroupServiceImpl.kt | 313 +- .../api/services/blocking/OrgSecretService.kt | 84 +- .../services/blocking/OrgSecretServiceImpl.kt | 330 +- .../services/blocking/OrganizationService.kt | 65 +- .../blocking/OrganizationServiceImpl.kt | 245 +- .../services/blocking/ProjectScoreService.kt | 86 +- .../blocking/ProjectScoreServiceImpl.kt | 347 +- .../api/services/blocking/ProjectService.kt | 70 +- .../services/blocking/ProjectServiceImpl.kt | 267 +- .../services/blocking/ProjectTagService.kt | 85 +- .../blocking/ProjectTagServiceImpl.kt | 346 +- .../api/services/blocking/PromptService.kt | 84 +- .../services/blocking/PromptServiceImpl.kt | 315 +- .../api/services/blocking/RoleService.kt | 83 +- .../api/services/blocking/RoleServiceImpl.kt | 313 +- .../api/services/blocking/TopLevelService.kt | 44 +- .../services/blocking/TopLevelServiceImpl.kt | 73 +- .../api/services/blocking/UserService.kt | 48 +- .../api/services/blocking/UserServiceImpl.kt | 127 +- .../api/services/blocking/ViewService.kt | 83 +- .../api/services/blocking/ViewServiceImpl.kt | 311 +- .../blocking/organization/MemberService.kt | 39 +- .../organization/MemberServiceImpl.kt | 82 +- .../blocking/organizations/MemberService.kt | 18 - .../organizations/MemberServiceImpl.kt | 54 - .../services/blocking/project/LogService.kt | 62 +- .../blocking/project/LogServiceImpl.kt | 236 +- .../services/blocking/projects/LogService.kt | 46 - .../blocking/projects/LogServiceImpl.kt | 142 - .../braintrustdata/api/TestServerExtension.kt | 8 +- .../api/core/http/HttpRequestTest.kt | 18 +- .../api/core/http/RetryingHttpClientTest.kt | 71 +- .../api/core/http/SerializerTest.kt | 40 +- .../api/models/AclCreateParamsTest.kt | 83 +- .../api/models/AclDeleteParamsTest.kt | 33 +- .../api/models/AclListParamsTest.kt | 78 +- .../api/models/AclRetrieveParamsTest.kt | 34 +- .../com/braintrustdata/api/models/AclTest.kt | 56 +- .../api/models/ApiKeyCreateParamsTest.kt | 32 - .../api/models/ApiKeyCreateResponseTest.kt | 33 - .../api/models/ApiKeyDeleteParamsTest.kt | 26 - .../api/models/ApiKeyListParamsTest.kt | 53 - .../models/ApiKeyResourceCreateParamsTest.kt | 44 +- .../models/ApiKeyResourceDeleteParamsTest.kt | 38 +- .../models/ApiKeyResourceListParamsTest.kt | 76 +- .../ApiKeyResourceRetrieveParamsTest.kt | 38 +- .../api/models/ApiKeyRetrieveParamsTest.kt | 26 - .../braintrustdata/api/models/ApiKeyTest.kt | 40 +- .../api/models/CreateAclTest.kt | 32 - .../api/models/CreateApiKeyOutputTest.kt | 45 +- .../api/models/CreateDatasetTest.kt | 23 - .../api/models/CreateExperimentTest.kt | 63 - .../api/models/CreateFunctionTest.kt | 183 - .../api/models/CreateGroupTest.kt | 29 - .../api/models/CreateProjectScoreTest.kt | 36 - .../api/models/CreateProjectTagTest.kt | 25 - .../api/models/CreateProjectTest.kt | 17 - .../api/models/CreatePromptTest.kt | 168 - .../api/models/CreateRoleTest.kt | 42 - .../api/models/CreateViewTest.kt | 72 - .../models/CrossObjectInsertRequestTest.kt | 26 - .../models/CrossObjectInsertResponseTest.kt | 32 +- .../api/models/DataSummaryTest.kt | 18 +- .../api/models/DatasetCreateParamsTest.kt | 57 +- .../api/models/DatasetDeleteParamsTest.kt | 34 +- .../api/models/DatasetEventTest.kt | 62 +- .../api/models/DatasetFeedbackParamsTest.kt | 123 +- .../api/models/DatasetFetchParamsTest.kt | 80 +- .../api/models/DatasetFetchPostParamsTest.kt | 133 +- .../models/DatasetFetchPostResponseTest.kt | 54 - .../api/models/DatasetFetchResponseTest.kt | 54 - .../api/models/DatasetInsertParamsTest.kt | 171 +- .../api/models/DatasetInsertResponseTest.kt | 16 - .../api/models/DatasetListParamsTest.kt | 87 +- .../api/models/DatasetRetrieveParamsTest.kt | 36 +- .../api/models/DatasetSummarizeParamsTest.kt | 66 +- .../models/DatasetSummarizeResponseTest.kt | 30 - .../braintrustdata/api/models/DatasetTest.kt | 48 +- .../api/models/DatasetUpdateParamsTest.kt | 75 +- .../api/models/DeleteViewTest.kt | 21 - .../api/models/ExperimentCreateParamsTest.kt | 169 +- .../api/models/ExperimentDeleteParamsTest.kt | 38 +- .../api/models/ExperimentEventTest.kt | 161 +- .../models/ExperimentFeedbackParamsTest.kt | 134 +- .../api/models/ExperimentFetchParamsTest.kt | 84 +- .../models/ExperimentFetchPostParamsTest.kt | 133 +- .../models/ExperimentFetchPostResponseTest.kt | 106 - .../api/models/ExperimentFetchResponseTest.kt | 106 - .../api/models/ExperimentInsertParamsTest.kt | 309 +- .../models/ExperimentInsertResponseTest.kt | 17 - .../api/models/ExperimentListParamsTest.kt | 87 +- .../models/ExperimentRetrieveParamsTest.kt | 38 +- .../models/ExperimentSummarizeParamsTest.kt | 72 +- .../models/ExperimentSummarizeResponseTest.kt | 34 - .../api/models/ExperimentTest.kt | 118 +- .../api/models/ExperimentUpdateParamsTest.kt | 176 +- .../models/FeedbackDatasetEventRequestTest.kt | 36 - .../api/models/FeedbackDatasetItemTest.kt | 34 +- .../FeedbackExperimentEventRequestTest.kt | 41 - .../api/models/FeedbackExperimentItemTest.kt | 45 +- .../FeedbackProjectLogsEventRequestTest.kt | 41 - .../api/models/FeedbackProjectLogsItemTest.kt | 45 +- .../api/models/FeedbackResponseSchemaTest.kt | 19 +- .../models/FetchDatasetEventsResponseTest.kt | 80 +- .../api/models/FetchEventsRequestTest.kt | 45 - .../FetchExperimentEventsResponseTest.kt | 176 +- .../FetchProjectLogsEventsResponseTest.kt | 176 +- .../api/models/FunctionCreateParamsTest.kt | 511 +- .../api/models/FunctionDeleteParamsTest.kt | 36 +- .../api/models/FunctionListParamsTest.kt | 99 +- .../api/models/FunctionReplaceParamsTest.kt | 511 +- .../api/models/FunctionRetrieveParamsTest.kt | 36 +- .../braintrustdata/api/models/FunctionTest.kt | 335 +- .../api/models/FunctionUpdateParamsTest.kt | 446 +- .../api/models/GroupCreateParamsTest.kt | 69 +- .../api/models/GroupDeleteParamsTest.kt | 34 +- .../api/models/GroupListParamsTest.kt | 73 +- .../api/models/GroupReplaceParamsTest.kt | 69 +- .../api/models/GroupRetrieveParamsTest.kt | 34 +- .../braintrustdata/api/models/GroupTest.kt | 52 +- .../api/models/GroupUpdateParamsTest.kt | 95 +- .../api/models/InsertDatasetEventMergeTest.kt | 56 +- .../models/InsertDatasetEventReplaceTest.kt | 57 +- .../models/InsertDatasetEventRequestTest.kt | 52 - .../api/models/InsertEventsResponseTest.kt | 18 +- .../models/InsertExperimentEventMergeTest.kt | 155 +- .../InsertExperimentEventReplaceTest.kt | 155 +- .../InsertExperimentEventRequestTest.kt | 104 - .../models/InsertProjectLogsEventMergeTest.kt | 151 +- .../InsertProjectLogsEventReplaceTest.kt | 151 +- .../InsertProjectLogsEventRequestTest.kt | 102 - .../api/models/MetricSummaryTest.kt | 41 +- .../api/models/OrgSecretCreateParamsTest.kt | 69 +- .../api/models/OrgSecretDeleteParamsTest.kt | 36 +- .../api/models/OrgSecretListParamsTest.kt | 84 +- .../api/models/OrgSecretReplaceParamsTest.kt | 69 +- .../api/models/OrgSecretRetrieveParamsTest.kt | 38 +- .../api/models/OrgSecretTest.kt | 44 +- .../api/models/OrgSecretUpdateParamsTest.kt | 85 +- .../models/OrganizationDeleteParamsTest.kt | 38 +- .../api/models/OrganizationListParamsTest.kt | 70 +- .../OrganizationMemberUpdateParamsTest.kt | 139 +- .../OrganizationMemberUpdateResponseTest.kt | 26 +- .../models/OrganizationRetrieveParamsTest.kt | 38 +- .../api/models/OrganizationTest.kt | 45 +- .../models/OrganizationUpdateParamsTest.kt | 91 +- .../api/models/PatchDatasetTest.kt | 23 - .../api/models/PatchExperimentTest.kt | 58 - .../api/models/PatchFunctionTest.kt | 179 - .../api/models/PatchGroupTest.kt | 33 - .../models/PatchOrganizationMembersTest.kt | 53 - .../api/models/PatchOrganizationTest.kt | 27 - .../api/models/PatchProjectScoreTest.kt | 34 - .../api/models/PatchProjectTagTest.kt | 19 - .../api/models/PatchProjectTest.kt | 22 - .../api/models/PatchPromptTest.kt | 164 - .../api/models/PatchRoleTest.kt | 65 - .../api/models/PatchViewTest.kt | 68 - .../api/models/PathLookupFilterTest.kt | 30 +- .../api/models/ProjectCreateParamsTest.kt | 44 +- .../api/models/ProjectDeleteParamsTest.kt | 34 +- .../api/models/ProjectListParamsTest.kt | 75 +- .../models/ProjectLogFeedbackParamsTest.kt | 134 +- .../api/models/ProjectLogFetchParamsTest.kt | 84 +- .../models/ProjectLogFetchPostParamsTest.kt | 133 +- .../models/ProjectLogFetchPostResponseTest.kt | 106 - .../api/models/ProjectLogFetchResponseTest.kt | 106 - .../api/models/ProjectLogInsertParamsTest.kt | 303 +- .../models/ProjectLogInsertResponseTest.kt | 17 - .../api/models/ProjectLogsEventTest.kt | 162 +- .../api/models/ProjectRetrieveParamsTest.kt | 36 +- .../api/models/ProjectScoreCategoryTest.kt | 21 +- .../models/ProjectScoreCreateParamsTest.kt | 98 +- .../models/ProjectScoreDeleteParamsTest.kt | 38 +- .../api/models/ProjectScoreListParamsTest.kt | 110 +- .../models/ProjectScoreReplaceParamsTest.kt | 98 +- .../models/ProjectScoreRetrieveParamsTest.kt | 38 +- .../api/models/ProjectScoreTest.kt | 147 +- .../models/ProjectScoreUpdateParamsTest.kt | 107 +- .../api/models/ProjectTagCreateParamsTest.kt | 70 +- .../api/models/ProjectTagDeleteParamsTest.kt | 38 +- .../api/models/ProjectTagListParamsTest.kt | 87 +- .../api/models/ProjectTagReplaceParamsTest.kt | 70 +- .../models/ProjectTagRetrieveParamsTest.kt | 38 +- .../api/models/ProjectTagTest.kt | 44 +- .../api/models/ProjectTagUpdateParamsTest.kt | 79 +- .../braintrustdata/api/models/ProjectTest.kt | 49 +- .../api/models/ProjectUpdateParamsTest.kt | 82 +- .../api/models/PromptCreateParamsTest.kt | 422 +- .../api/models/PromptDataTest.kt | 224 +- .../api/models/PromptDeleteParamsTest.kt | 34 +- .../api/models/PromptListParamsTest.kt | 97 +- .../api/models/PromptReplaceParamsTest.kt | 422 +- .../api/models/PromptRetrieveParamsTest.kt | 34 +- .../braintrustdata/api/models/PromptTest.kt | 289 +- .../api/models/PromptUpdateParamsTest.kt | 417 +- .../braintrustdata/api/models/RepoInfoTest.kt | 53 +- .../api/models/RoleCreateParamsTest.kt | 106 +- .../api/models/RoleDeleteParamsTest.kt | 34 +- .../api/models/RoleListParamsTest.kt | 73 +- .../api/models/RoleReplaceParamsTest.kt | 106 +- .../api/models/RoleRetrieveParamsTest.kt | 34 +- .../com/braintrustdata/api/models/RoleTest.kt | 73 +- .../api/models/RoleUpdateParamsTest.kt | 169 +- .../api/models/ScoreSummaryTest.kt | 37 +- .../models/SummarizeDatasetResponseTest.kt | 42 +- .../models/SummarizeExperimentResponseTest.kt | 48 +- .../models/TopLevelHelloWorldParamsTest.kt | 16 +- .../api/models/UserListParamsTest.kt | 85 +- .../api/models/UserRetrieveParamsTest.kt | 34 +- .../com/braintrustdata/api/models/UserTest.kt | 40 +- .../api/models/ViewCreateParamsTest.kt | 180 +- .../api/models/ViewDataSearchTest.kt | 34 +- .../braintrustdata/api/models/ViewDataTest.kt | 47 +- .../api/models/ViewDeleteParamsTest.kt | 79 +- .../api/models/ViewListParamsTest.kt | 90 +- .../api/models/ViewOptionsTest.kt | 30 +- .../api/models/ViewReplaceParamsTest.kt | 180 +- .../api/models/ViewRetrieveParamsTest.kt | 78 +- .../com/braintrustdata/api/models/ViewTest.kt | 115 +- .../api/models/ViewUpdateParamsTest.kt | 194 +- .../api/services/ErrorHandlingTest.kt | 435 +- .../api/services/ServiceParamsTest.kt | 113 +- .../api/services/blocking/AclServiceTest.kt | 126 +- .../blocking/ApiKeyResourceServiceTest.kt | 112 +- .../services/blocking/ApiKeyServiceTest.kt | 79 - .../services/blocking/DatasetServiceTest.kt | 345 +- .../blocking/ExperimentServiceTest.kt | 469 +- .../services/blocking/FunctionServiceTest.kt | 589 +-- .../api/services/blocking/GroupServiceTest.kt | 187 +- .../services/blocking/OrgSecretServiceTest.kt | 185 +- .../blocking/OrganizationServiceTest.kt | 123 +- .../blocking/ProjectScoreServiceTest.kt | 206 +- .../services/blocking/ProjectServiceTest.kt | 146 +- .../blocking/ProjectTagServiceTest.kt | 179 +- .../services/blocking/PromptServiceTest.kt | 537 +- .../api/services/blocking/RoleServiceTest.kt | 239 +- .../services/blocking/TopLevelServiceTest.kt | 38 +- .../api/services/blocking/UserServiceTest.kt | 63 +- .../api/services/blocking/ViewServiceTest.kt | 300 +- .../organization/MemberServiceTest.kt | 75 +- .../organizations/MemberServiceTest.kt | 47 - .../blocking/project/LogServiceTest.kt | 244 +- .../blocking/projects/LogServiceTest.kt | 161 - .../main/kotlin/braintrust.publish.gradle.kts | 2 +- gradle/wrapper/gradle-wrapper.jar | Bin 564 files changed, 49812 insertions(+), 73327 deletions(-) delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateAcl.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateDataset.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateExperiment.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateFunction.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateGroup.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProject.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectScore.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectTag.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreatePrompt.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateRole.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateView.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequest.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DeleteView.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequest.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequest.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequest.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchEventsRequest.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Ids.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequest.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequest.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequest.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchDataset.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchExperiment.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchFunction.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchGroup.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganization.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembers.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProject.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectScore.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectTag.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchPrompt.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchRole.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchView.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserEmail.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserFamilyName.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserGivenName.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt delete mode 100755 braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateAclTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateDatasetTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateExperimentTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateFunctionTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateGroupTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectScoreTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTagTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreatePromptTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateRoleTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateViewTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequestTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DeleteViewTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequestTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequestTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequestTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchEventsRequestTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequestTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequestTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequestTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchDatasetTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchExperimentTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchFunctionTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchGroupTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectScoreTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTagTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchPromptTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchRoleTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchViewTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponseTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt delete mode 100755 braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt mode change 100755 => 100644 gradle/wrapper/gradle-wrapper.jar diff --git a/SECURITY.md b/SECURITY.md index 17cb8abe..9e161b9a 100755 --- a/SECURITY.md +++ b/SECURITY.md @@ -20,7 +20,7 @@ or products provided by Braintrust please follow the respective company's securi ### Braintrust Terms and Policies -Please contact infotest@braintrustdata.com for any questions or concerns regarding security of our services. +Please contact info@braintrustdata.com for any questions or concerns regarding security of our services. --- diff --git a/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt b/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt index 4c7f0fac..fd80a540 100755 --- a/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt +++ b/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClient.kt @@ -2,13 +2,16 @@ package com.braintrustdata.api.client.okhttp -import com.braintrustdata.api.client.BraintrustClient -import com.braintrustdata.api.client.BraintrustClientImpl -import com.braintrustdata.api.core.ClientOptions import com.fasterxml.jackson.databind.json.JsonMapper +import com.google.common.collect.Multimap import java.net.Proxy import java.time.Clock import java.time.Duration +import java.util.Optional +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpClient +import com.braintrustdata.api.client.BraintrustClient +import com.braintrustdata.api.client.BraintrustClientImpl class BraintrustOkHttpClient private constructor() { @@ -32,15 +35,21 @@ class BraintrustOkHttpClient private constructor() { this.baseUrl = baseUrl } - fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + fun jsonMapper(jsonMapper: JsonMapper) = apply { + clientOptions.jsonMapper(jsonMapper) + } - fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + fun clock(clock: Clock) = apply { + clientOptions.clock(clock) + } fun headers(headers: Map>) = apply { clientOptions.headers(headers) } - fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + fun putHeader(name: String, value: String) = apply { + clientOptions.putHeader(name, value) + } fun putHeaders(name: String, values: Iterable) = apply { clientOptions.putHeaders(name, values) @@ -50,34 +59,42 @@ class BraintrustOkHttpClient private constructor() { clientOptions.putAllHeaders(headers) } - fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) } + fun removeHeader(name: String) = apply { + clientOptions.removeHeader(name) + } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Duration) = apply { + this.timeout = timeout + } - 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 apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + fun apiKey(apiKey: String?) = apply { + clientOptions.apiKey(apiKey) + } - fun fromEnv() = apply { clientOptions.fromEnv() } + fun fromEnv() = apply { + clientOptions.fromEnv() + } fun build(): BraintrustClient { - return BraintrustClientImpl( - clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(baseUrl) - .timeout(timeout) - .proxy(proxy) - .build() - ) - .build() - ) + return BraintrustClientImpl(clientOptions + .httpClient(OkHttpClient.builder() + .baseUrl(baseUrl) + .timeout(timeout) + .proxy(proxy) + .build()) + .build()) } } } diff --git a/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt b/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt index 0b34647a..bece877a 100755 --- a/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt +++ b/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/BraintrustOkHttpClientAsync.kt @@ -2,13 +2,16 @@ package com.braintrustdata.api.client.okhttp -import com.braintrustdata.api.client.BraintrustClientAsync -import com.braintrustdata.api.client.BraintrustClientAsyncImpl -import com.braintrustdata.api.core.ClientOptions import com.fasterxml.jackson.databind.json.JsonMapper +import com.google.common.collect.Multimap import java.net.Proxy import java.time.Clock import java.time.Duration +import java.util.Optional +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpClient +import com.braintrustdata.api.client.BraintrustClientAsync +import com.braintrustdata.api.client.BraintrustClientAsyncImpl class BraintrustOkHttpClientAsync private constructor() { @@ -32,15 +35,21 @@ class BraintrustOkHttpClientAsync private constructor() { this.baseUrl = baseUrl } - fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + fun jsonMapper(jsonMapper: JsonMapper) = apply { + clientOptions.jsonMapper(jsonMapper) + } - fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + fun clock(clock: Clock) = apply { + clientOptions.clock(clock) + } fun headers(headers: Map>) = apply { clientOptions.headers(headers) } - fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + fun putHeader(name: String, value: String) = apply { + clientOptions.putHeader(name, value) + } fun putHeaders(name: String, values: Iterable) = apply { clientOptions.putHeaders(name, values) @@ -50,34 +59,42 @@ class BraintrustOkHttpClientAsync private constructor() { clientOptions.putAllHeaders(headers) } - fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) } + fun removeHeader(name: String) = apply { + clientOptions.removeHeader(name) + } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Duration) = apply { + this.timeout = timeout + } - 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 apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + fun apiKey(apiKey: String?) = apply { + clientOptions.apiKey(apiKey) + } - fun fromEnv() = apply { clientOptions.fromEnv() } + fun fromEnv() = apply { + clientOptions.fromEnv() + } fun build(): BraintrustClientAsync { - return BraintrustClientAsyncImpl( - clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(baseUrl) - .timeout(timeout) - .proxy(proxy) - .build() - ) - .build() - ) + return BraintrustClientAsyncImpl(clientOptions + .httpClient(OkHttpClient.builder() + .baseUrl(baseUrl) + .timeout(timeout) + .proxy(proxy) + .build()) + .build()) } } } diff --git a/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt b/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt index c1d1d5d4..df689b13 100755 --- a/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt +++ b/braintrust-kotlin-client-okhttp/src/main/kotlin/com/braintrustdata/api/client/okhttp/OkHttpClient.kt @@ -1,30 +1,31 @@ package com.braintrustdata.api.client.okhttp +import com.google.common.collect.ListMultimap +import com.google.common.collect.MultimapBuilder import com.braintrustdata.api.core.RequestOptions 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 com.google.common.collect.ListMultimap -import com.google.common.collect.MultimapBuilder import java.io.IOException import java.io.InputStream import java.net.Proxy import java.time.Duration +import java.util.concurrent.TimeUnit import kotlinx.coroutines.suspendCancellableCoroutine import okhttp3.Call import okhttp3.Callback -import okhttp3.Headers 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.Headers +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MediaType.Companion.toMediaType import okhttp3.RequestBody.Companion.toRequestBody -import okhttp3.Response import okio.BufferedSink class OkHttpClient @@ -33,8 +34,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { val timeout = requestOptions.timeout ?: return okHttpClient - return okHttpClient - .newBuilder() + return okHttpClient.newBuilder() .connectTimeout(timeout) .readTimeout(timeout) .writeTimeout(timeout) @@ -190,20 +190,19 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } } - private suspend fun Call.executeAsync(): Response = - suspendCancellableCoroutine { continuation -> - continuation.invokeOnCancellation { this.cancel() } + private suspend fun Call.executeAsync(): Response = suspendCancellableCoroutine { continuation -> + continuation.invokeOnCancellation { this.cancel() } - enqueue( - object : Callback { - override fun onFailure(call: Call, e: IOException) { - continuation.resumeWith(Result.failure(e)) - } + enqueue( + object : Callback { + override fun onFailure(call: Call, e: IOException) { + continuation.resumeWith(Result.failure(e)) + } - override fun onResponse(call: Call, response: Response) { - continuation.resumeWith(Result.success(response)) - } + override fun onResponse(call: Call, response: Response) { + continuation.resumeWith(Result.success(response)) } - ) - } + } + ) + } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt index b4053a50..c53b5555 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClient.kt @@ -4,8 +4,27 @@ package com.braintrustdata.api.client +import java.time.Duration +import java.util.Base64 +import java.util.Optional +import java.util.concurrent.CompletableFuture +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.braintrustdata.api.services.blocking.* +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface BraintrustClient { diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt index dc12199a..fe5d2537 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsync.kt @@ -4,8 +4,27 @@ package com.braintrustdata.api.client +import java.time.Duration +import java.util.Base64 +import java.util.Optional +import java.util.concurrent.CompletableFuture +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.braintrustdata.api.services.async.* +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface BraintrustClientAsync { diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt index 556b4e18..4f837f27 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientAsyncImpl.kt @@ -2,17 +2,29 @@ package com.braintrustdata.api.client +import java.time.Duration +import java.util.Base64 +import java.util.Optional +import java.util.concurrent.CompletableFuture import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.braintrustdata.api.services.async.* +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler -class BraintrustClientAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : BraintrustClientAsync { +class BraintrustClientAsyncImpl constructor(private val clientOptions: ClientOptions, ) : BraintrustClientAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -22,9 +34,7 @@ constructor( private val project: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptions) } - private val experiment: ExperimentServiceAsync by lazy { - ExperimentServiceAsyncImpl(clientOptions) - } + private val experiment: ExperimentServiceAsync by lazy { ExperimentServiceAsyncImpl(clientOptions) } private val dataset: DatasetServiceAsync by lazy { DatasetServiceAsyncImpl(clientOptions) } @@ -38,29 +48,19 @@ constructor( private val user: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptions) } - private val projectScore: ProjectScoreServiceAsync by lazy { - ProjectScoreServiceAsyncImpl(clientOptions) - } + private val projectScore: ProjectScoreServiceAsync by lazy { ProjectScoreServiceAsyncImpl(clientOptions) } - private val projectTag: ProjectTagServiceAsync by lazy { - ProjectTagServiceAsyncImpl(clientOptions) - } + private val projectTag: ProjectTagServiceAsync by lazy { ProjectTagServiceAsyncImpl(clientOptions) } private val function: FunctionServiceAsync by lazy { FunctionServiceAsyncImpl(clientOptions) } private val view: ViewServiceAsync by lazy { ViewServiceAsyncImpl(clientOptions) } - private val organization: OrganizationServiceAsync by lazy { - OrganizationServiceAsyncImpl(clientOptions) - } + private val organization: OrganizationServiceAsync by lazy { OrganizationServiceAsyncImpl(clientOptions) } - private val apiKeyResource: ApiKeyResourceServiceAsync by lazy { - ApiKeyResourceServiceAsyncImpl(clientOptions) - } + private val apiKeyResource: ApiKeyResourceServiceAsync by lazy { ApiKeyResourceServiceAsyncImpl(clientOptions) } - private val orgSecret: OrgSecretServiceAsync by lazy { - OrgSecretServiceAsyncImpl(clientOptions) - } + private val orgSecret: OrgSecretServiceAsync by lazy { OrgSecretServiceAsyncImpl(clientOptions) } override fun sync(): BraintrustClient = sync diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt index 700ede21..f3af2535 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/client/BraintrustClientImpl.kt @@ -2,17 +2,29 @@ package com.braintrustdata.api.client +import java.time.Duration +import java.util.Base64 +import java.util.Optional +import java.util.concurrent.CompletableFuture import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* import com.braintrustdata.api.services.blocking.* +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler -class BraintrustClientImpl -constructor( - private val clientOptions: ClientOptions, -) : BraintrustClient { +class BraintrustClientImpl constructor(private val clientOptions: ClientOptions, ) : BraintrustClient { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -46,9 +58,7 @@ constructor( private val organization: OrganizationService by lazy { OrganizationServiceImpl(clientOptions) } - private val apiKeyResource: ApiKeyResourceService by lazy { - ApiKeyResourceServiceImpl(clientOptions) - } + private val apiKeyResource: ApiKeyResourceService by lazy { ApiKeyResourceServiceImpl(clientOptions) } private val orgSecret: OrgSecretService by lazy { OrgSecretServiceImpl(clientOptions) } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt index a38e39bd..a197b7fe 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/BaseDeserializer.kt +++ b/braintrust-kotlin-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-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt index 2208167f..0c20e479 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/ClientOptions.kt @@ -2,23 +2,25 @@ package com.braintrustdata.api.core -import com.braintrustdata.api.core.http.HttpClient -import com.braintrustdata.api.core.http.RetryingHttpClient import com.fasterxml.jackson.databind.json.JsonMapper -import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.Multimap import com.google.common.collect.ListMultimap +import com.google.common.collect.ArrayListMultimap import java.time.Clock +import java.util.Base64 +import com.braintrustdata.api.core.http.HttpClient +import com.braintrustdata.api.core.http.RetryingHttpClient + +class ClientOptions private constructor( + val httpClient: HttpClient, + val jsonMapper: JsonMapper, + val clock: Clock, + val baseUrl: String, + val apiKey: String?, + val headers: ListMultimap, + val queryParams: ListMultimap, + val responseValidation: Boolean, -class ClientOptions -private constructor( - val httpClient: HttpClient, - val jsonMapper: JsonMapper, - val clock: Clock, - val baseUrl: String, - val apiKey: String?, - val headers: ListMultimap, - val queryParams: ListMultimap, - val responseValidation: Boolean, ) { companion object { @@ -42,13 +44,21 @@ private constructor( private var maxRetries: Int = 2 private var apiKey: String? = null - 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 baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun baseUrl(baseUrl: String) = apply { + this.baseUrl = baseUrl + } - fun clock(clock: Clock) = apply { this.clock = clock } + fun clock(clock: Clock) = apply { + this.clock = clock + } fun headers(headers: Map>) = apply { this.headers.clear() @@ -67,7 +77,9 @@ private constructor( headers.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.headers.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.headers.put(name, mutableListOf()) + } fun queryParams(queryParams: Map>) = apply { this.queryParams.clear() @@ -86,49 +98,61 @@ private constructor( queryParams.forEach(this::putQueryParams) } - fun removeQueryParam(name: String) = apply { this.queryParams.put(name, mutableListOf()) } + fun removeQueryParam(name: String) = apply { + this.queryParams.put(name, mutableListOf()) + } fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } - 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 fromEnv() = apply { System.getenv("BRAINTRUST_API_KEY")?.let { apiKey(it) } } + fun fromEnv() = apply { + System.getenv("BRAINTRUST_API_KEY")?.let { + apiKey(it) + } + } fun build(): ClientOptions { - checkNotNull(httpClient) { "`httpClient` is required but was not set" } - - val headers = ArrayListMultimap.create() - val queryParams = ArrayListMultimap.create() - headers.put("X-Stainless-Lang", "kotlin") - 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-Version", getJavaVersion()) - if (!apiKey.isNullOrEmpty()) { - headers.put("Authorization", "Bearer ${apiKey}") - } - this.headers.forEach(headers::replaceValues) - this.queryParams.forEach(queryParams::replaceValues) - - return ClientOptions( - RetryingHttpClient.builder() - .httpClient(httpClient!!) - .clock(clock) - .maxRetries(maxRetries) - .build(), - jsonMapper ?: jsonMapper(), - clock, - baseUrl, - apiKey, - headers.toUnmodifiable(), - queryParams.toUnmodifiable(), - responseValidation, - ) + checkNotNull(httpClient) { + "`httpClient` is required but was not set" + } + + val headers = ArrayListMultimap.create() + val queryParams = ArrayListMultimap.create() + headers.put("X-Stainless-Lang", "kotlin") + 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-Version", getJavaVersion()) + if (!apiKey.isNullOrEmpty()) { + headers.put("Authorization", "Bearer ${apiKey}") + } + this.headers.forEach(headers::replaceValues) + this.queryParams.forEach(queryParams::replaceValues) + + return ClientOptions( + RetryingHttpClient.builder() + .httpClient(httpClient!!) + .clock(clock) + .maxRetries(maxRetries) + .build(), + jsonMapper ?: jsonMapper(), + clock, + baseUrl, + apiKey, + headers.toUnmodifiable(), + queryParams.toUnmodifiable(), + responseValidation, + ) } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt index 1c59eee1..e04d1393 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Properties.kt +++ b/braintrust-kotlin-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}" } @@ -39,7 +36,7 @@ fun getOsVersion(): String { } fun getPackageVersion(): String { - return Properties::class.java.`package`.implementationVersion ?: "unknown" + return Properties::class.java.`package`.implementationVersion ?: "unknown"; } fun getJavaVersion(): String { diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt index b03a0cf0..092f0f4d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/RequestOptions.kt @@ -31,7 +31,9 @@ private constructor( this.responseValidation = responseValidation } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Duration) = apply { + this.timeout = timeout + } fun build(): RequestOptions { return RequestOptions(responseValidation, timeout) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt index 2696a957..3133a760 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Utils.kt @@ -2,10 +2,10 @@ package com.braintrustdata.api.core -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.google.common.collect.ImmutableListMultimap import com.google.common.collect.ListMultimap import com.google.common.collect.Multimaps +import com.braintrustdata.api.errors.BraintrustInvalidDataException import java.util.Collections internal fun T?.getOrThrow(name: String): T { @@ -43,10 +43,10 @@ internal fun ListMultimap.toUnmodifiable(): ListMultimap { internal fun ListMultimap.getRequiredHeader(header: String): String { val value = entries() - .stream() - .filter { entry -> entry.key.equals(header, ignoreCase = true) } - .map { entry -> entry.value } - .findFirst() + .stream() + .filter { entry -> entry.key.equals(header, ignoreCase = true) } + .map { entry -> entry.value } + .findFirst() if (!value.isPresent) { throw BraintrustInvalidDataException("Could not find $header header") } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt index 964db27d..79ade1c6 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/Values.kt @@ -1,12 +1,12 @@ package com.braintrustdata.api.core -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JacksonAnnotationsInside import com.fasterxml.jackson.annotation.JsonAutoDetect import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.BeanProperty @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.deser.ContextualDeserializer +import com.fasterxml.jackson.databind.deser.std.StdDeserializer import com.fasterxml.jackson.databind.node.JsonNodeType.ARRAY import com.fasterxml.jackson.databind.node.JsonNodeType.BINARY import com.fasterxml.jackson.databind.node.JsonNodeType.BOOLEAN @@ -28,13 +30,15 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.nio.charset.Charset import java.util.Objects -import kotlin.reflect.KClass +import java.io.ByteArrayOutputStream import org.apache.hc.core5.http.ContentType +import java.nio.charset.Charset +import kotlin.reflect.KClass +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(using = JsonField.Deserializer::class) -sealed class JsonField { +sealed class JsonField { fun isMissing(): Boolean = this is JsonMissing @@ -47,8 +51,8 @@ sealed class JsonField { } /** - * If the "known" value (i.e. matching the type that the SDK expects) is returned by the API - * then this method will return `null`, otherwise a `JsonValue` is returned. + * If the "known" value (i.e. matching the type that the SDK expects) is returned + * by the API then this method will return `null`, otherwise a `JsonValue` is returned. */ fun asUnknown(): JsonValue? = when (this) { @@ -74,6 +78,7 @@ sealed class JsonField { else -> null } + fun asStringOrThrow(): String = when (this) { is JsonString -> value @@ -120,7 +125,7 @@ sealed class JsonField { is JsonValue -> accept(visitor as JsonValue.Visitor) } - interface Visitor : JsonValue.Visitor { + interface Visitor: JsonValue.Visitor { fun visitKnown(value: T): R = visitDefault() } @@ -151,8 +156,11 @@ sealed class JsonField { } override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> { - return type?.let { tryDeserialize(node, type) }?.let { of(it) } - ?: JsonValue.fromJsonNode(node) + return type?.let { + tryDeserialize(node, type) + }?.let { + of(it) + } ?: JsonValue.fromJsonNode(node) } override fun getNullValue(context: DeserializationContext): JsonField<*> { @@ -162,13 +170,13 @@ sealed class JsonField { } @JsonDeserialize(using = JsonValue.Deserializer::class) -sealed class JsonValue : JsonField() { +sealed class JsonValue: JsonField() { - inline fun convert(): R? = convert(jacksonTypeRef()) + inline fun convert(): R? = convert(jacksonTypeRef()) - fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) + fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) - fun convert(type: KClass): R? = JSON_MAPPER.convertValue(this, type.java) + fun convert(type: KClass): R? = JSON_MAPPER.convertValue(this, type.java) fun accept(visitor: Visitor): R = when (this) { @@ -183,19 +191,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") } @@ -219,12 +220,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}") @@ -242,10 +239,7 @@ sealed class JsonValue : JsonField() { } } -class KnownValue -private constructor( - @com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T -) : JsonField() { +class KnownValue private constructor(@com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T) : JsonField() { override fun equals(other: Any?): Boolean { if (this === other) { @@ -260,7 +254,7 @@ private constructor( override fun toString() = value.toString() companion object { - @JsonCreator fun of(value: T) = KnownValue(value) + @JsonCreator fun of(value: T) = KnownValue(value) } } @@ -275,12 +269,8 @@ class JsonMissing : JsonValue() { 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") } } @@ -383,7 +373,8 @@ private constructor( override fun toString() = values.toString() companion object { - @JsonCreator fun of(values: List) = JsonArray(values.toUnmodifiable()) + @JsonCreator + fun of(values: List) = JsonArray(values.toUnmodifiable()) } } @@ -407,7 +398,8 @@ private constructor( override fun toString() = values.toString() companion object { - @JsonCreator fun of(values: Map) = JsonObject(values.toUnmodifiable()) + @JsonCreator + fun of(values: Map) = JsonObject(values.toUnmodifiable()) } } @@ -424,12 +416,11 @@ annotation class ExcludeMissing isGetterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, creatorVisibility = Visibility.NONE, - fieldVisibility = Visibility.NONE -) + fieldVisibility = Visibility.NONE) annotation class NoAutoDetect -class MultipartFormValue -internal constructor( + +class MultipartFormValue internal constructor( val name: String, val value: T, val contentType: ContentType, @@ -440,20 +431,16 @@ internal constructor( override fun hashCode(): Int { if (hashCode == 0) { - hashCode = - Objects.hash( - name, - contentType, - filename, - when (value) { - is ByteArray -> value.contentHashCode() - is String -> value - is Boolean -> value - is Long -> value - is Double -> value - else -> value?.hashCode() - } - ) + hashCode = Objects.hash( + name, contentType, filename, when (value) { + is ByteArray -> value.contentHashCode() + is String -> value + is Boolean -> value + is Long -> value + is Double -> value + else -> value?.hashCode() + } + ) } return hashCode } @@ -464,8 +451,7 @@ internal constructor( other as MultipartFormValue<*> - if (name != other.name || contentType != other.contentType || filename != other.filename) - return false + if (name != other.name || contentType != other.contentType || filename != other.filename) return false return when { value is ByteArray && other.value is ByteArray -> value contentEquals other.value @@ -477,11 +463,10 @@ internal constructor( return "MultipartFormValue(name='$name', contentType=$contentType, filename=$filename, value=${valueToString()})" } - private fun valueToString(): String = - when (value) { - is ByteArray -> "ByteArray of size ${value.size}" - else -> value.toString() - } + private fun valueToString(): String = when (value) { + is ByteArray -> "ByteArray of size ${value.size}" + else -> value.toString() + } companion object { internal fun fromString( @@ -491,27 +476,27 @@ internal constructor( ): MultipartFormValue = MultipartFormValue(name, value, contentType) internal fun fromBoolean( - name: String, - value: Boolean, - contentType: ContentType, + name: String, + value: Boolean, + contentType: ContentType, ): MultipartFormValue = MultipartFormValue(name, value, contentType) internal fun fromLong( - name: String, - value: Long, - contentType: ContentType, + name: String, + value: Long, + contentType: ContentType, ): MultipartFormValue = MultipartFormValue(name, value, contentType) internal fun fromDouble( - name: String, - value: Double, - contentType: ContentType, + name: String, + value: Double, + contentType: ContentType, ): MultipartFormValue = MultipartFormValue(name, value, contentType) - internal fun fromEnum( - name: String, - value: T, - contentType: ContentType + internal fun fromEnum( + name: String, + value: T, + contentType: ContentType ): MultipartFormValue = MultipartFormValue(name, value, contentType) internal fun fromByteArray( diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt index 324cfe2d..44ff4a58 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/BinaryResponseContent.kt @@ -1,5 +1,6 @@ package com.braintrustdata.api.core.http +import com.google.common.collect.ListMultimap import java.io.IOException import java.io.InputStream import java.io.OutputStream diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt index f4eb2573..593953d0 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpClient.kt @@ -1,7 +1,7 @@ package com.braintrustdata.api.core.http -import com.braintrustdata.api.core.RequestOptions import java.lang.AutoCloseable +import com.braintrustdata.api.core.RequestOptions interface HttpClient : AutoCloseable { diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt index e6f7a0a5..3cfbb9de 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequest.kt @@ -1,10 +1,11 @@ package com.braintrustdata.api.core.http -import com.braintrustdata.api.core.toUnmodifiable import com.google.common.collect.ArrayListMultimap import com.google.common.collect.ListMultimap import com.google.common.collect.Multimap import com.google.common.collect.MultimapBuilder +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.RequestOptions class HttpRequest private constructor( diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt index e5c7df37..d8f95580 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/HttpRequestBody.kt @@ -13,11 +13,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-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt index 2168afcf..82aafd7a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/core/http/RetryingHttpClient.kt @@ -2,8 +2,8 @@ package com.braintrustdata.api.core.http -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustIoException +import com.braintrustdata.api.core.RequestOptions import java.io.IOException import java.time.Clock import java.time.Duration @@ -21,15 +21,15 @@ import kotlinx.coroutines.delay 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, + request: HttpRequest, + requestOptions: RequestOptions, ): HttpResponse { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.execute(request, requestOptions) @@ -41,29 +41,29 @@ private constructor( while (true) { val response = - try { - val response = httpClient.execute(request, requestOptions) - if (++retries > maxRetries || !shouldRetry(response)) { - return response + try { + val response = httpClient.execute(request, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } + + response + } catch (t: Throwable) { + if (++retries > maxRetries || !shouldRetry(t)) { + throw t + } + + null } - response - } catch (t: Throwable) { - if (++retries > maxRetries || !shouldRetry(t)) { - throw t - } - - null - } - val backoffMillis = getRetryBackoffMillis(retries, response) Thread.sleep(backoffMillis.toMillis()) } } override suspend fun executeAsync( - request: HttpRequest, - requestOptions: RequestOptions, + request: HttpRequest, + requestOptions: RequestOptions, ): HttpResponse { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.executeAsync(request, requestOptions) @@ -75,21 +75,21 @@ private constructor( while (true) { val response = - try { - val response = httpClient.execute(request, requestOptions) - if (++retries > maxRetries || !shouldRetry(response)) { - return response + try { + val response = httpClient.execute(request, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } + + response + } catch (t: Throwable) { + if (++retries > maxRetries || !shouldRetry(t)) { + throw t + } + + null } - response - } catch (t: Throwable) { - if (++retries > maxRetries || !shouldRetry(t)) { - throw t - } - - null - } - val backoffMillis = getRetryBackoffMillis(retries, response) delay(backoffMillis.toKotlinDuration()) } @@ -145,38 +145,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 - .get("Retry-After-Ms") - .getOrNull(0) - ?.toFloatOrNull() - ?.times(TimeUnit.MILLISECONDS.toNanos(1)) + response?.headers()?.let { headers -> + headers.get("Retry-After-Ms").getOrNull(0)?.toFloatOrNull()?.times(TimeUnit.MILLISECONDS.toNanos(1)) ?: headers.get("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 + ?: try { + ChronoUnit.MILLIS.between( + OffsetDateTime.now(clock), + OffsetDateTime.parse( + retryAfter, + DateTimeFormatter.RFC_1123_DATE_TIME + ) ) - ) - } catch (e: DateTimeParseException) { - null - } + } 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) @@ -207,11 +199,11 @@ private constructor( fun idempotencyHeader(header: String) = apply { this.idempotencyHeader = header } fun build(): HttpClient = - RetryingHttpClient( - checkNotNull(httpClient) { "`httpClient` is required but was not set" }, - clock, - maxRetries, - idempotencyHeader, - ) + RetryingHttpClient( + checkNotNull(httpClient) { "`httpClient` is required but was not set" }, + clock, + maxRetries, + idempotencyHeader, + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt index a373ba5e..b9753acb 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BadRequestException.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.errors import com.google.common.collect.ListMultimap class BadRequestException( - headers: ListMultimap, - body: String, - error: BraintrustError, + headers: ListMultimap, + body: String, + error: BraintrustError, ) : BraintrustServiceException(400, headers, body, error) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt index e845c581..300edaff 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustError.kt @@ -2,42 +2,45 @@ package com.braintrustdata.api.errors -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime import java.util.Objects +import java.util.UUID +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.NoAutoDetect @JsonDeserialize(builder = BraintrustError.Builder::class) @NoAutoDetect -class BraintrustError -constructor( - private val additionalProperties: Map, -) { +class BraintrustError constructor(private val additionalProperties: Map, ) { - @JsonAnyGetter fun additionalProperties(): Map = additionalProperties + @JsonAnyGetter + fun additionalProperties(): Map = additionalProperties fun toBuilder() = Builder() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is BraintrustError && this.additionalProperties == other.additionalProperties + return other is BraintrustError && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(additionalProperties) + return Objects.hash(additionalProperties) } override fun toString() = "BraintrustError{additionalProperties=$additionalProperties}" companion object { - @JvmStatic fun builder() = Builder() + @JvmStatic + fun builder() = Builder() } class Builder { diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustException.kt index 5e8c12cf..0bdcaa59 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustException.kt @@ -1,4 +1,3 @@ package com.braintrustdata.api.errors -open class BraintrustException(message: String? = null, cause: Throwable? = null) : - RuntimeException(message, cause) +open class BraintrustException(message: String? = null, cause: Throwable? = null) : RuntimeException(message, cause) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt index 34f13c1f..f72f5651 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustInvalidDataException.kt @@ -1,4 +1,3 @@ package com.braintrustdata.api.errors -class BraintrustInvalidDataException(message: String? = null, cause: Throwable? = null) : - BraintrustException(message, cause) +class BraintrustInvalidDataException(message: String? = null, cause: Throwable? = null) : BraintrustException(message, cause) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt index ce1bfdb9..b4dbb68a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustIoException.kt @@ -1,4 +1,3 @@ package com.braintrustdata.api.errors -class BraintrustIoException(message: String? = null, cause: Throwable? = null) : - BraintrustException(message, cause) +class BraintrustIoException(message: String? = null, cause: Throwable? = null) : BraintrustException(message, cause) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt index 4838237f..a87a3af5 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/BraintrustServiceException.kt @@ -3,12 +3,12 @@ package com.braintrustdata.api.errors import com.google.common.collect.ListMultimap abstract class BraintrustServiceException( - private val statusCode: Int, - private val headers: ListMultimap, - private val body: String, - private val error: BraintrustError, - message: String = "$statusCode: $error", - cause: Throwable? = null + private val statusCode: Int, + private val headers: ListMultimap, + 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-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt index e43239e8..ef64cba0 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/InternalServerException.kt @@ -3,8 +3,8 @@ package com.braintrustdata.api.errors import com.google.common.collect.ListMultimap class InternalServerException( - statusCode: Int, - headers: ListMultimap, - body: String, - error: BraintrustError, + statusCode: Int, + headers: ListMultimap, + body: String, + error: BraintrustError, ) : BraintrustServiceException(statusCode, headers, body, error) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt index 8e879cbf..41b6dd67 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/NotFoundException.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.errors import com.google.common.collect.ListMultimap class NotFoundException( - headers: ListMultimap, - body: String, - error: BraintrustError, + headers: ListMultimap, + body: String, + error: BraintrustError, ) : BraintrustServiceException(404, headers, body, error) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt index 98c6f33e..08162432 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/PermissionDeniedException.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.errors import com.google.common.collect.ListMultimap class PermissionDeniedException( - headers: ListMultimap, - body: String, - error: BraintrustError, + headers: ListMultimap, + body: String, + error: BraintrustError, ) : BraintrustServiceException(403, headers, body, error) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt index d98aed03..9c3e0f13 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/RateLimitException.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.errors import com.google.common.collect.ListMultimap class RateLimitException( - headers: ListMultimap, - body: String, - error: BraintrustError, + headers: ListMultimap, + body: String, + error: BraintrustError, ) : BraintrustServiceException(429, headers, body, error) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt index 72236499..cc3c737f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnauthorizedException.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.errors import com.google.common.collect.ListMultimap class UnauthorizedException( - headers: ListMultimap, - body: String, - error: BraintrustError, + headers: ListMultimap, + body: String, + error: BraintrustError, ) : BraintrustServiceException(401, headers, body, error) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt index 7482559f..43739389 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnexpectedStatusCodeException.kt @@ -3,8 +3,8 @@ package com.braintrustdata.api.errors import com.google.common.collect.ListMultimap class UnexpectedStatusCodeException( - statusCode: Int, - headers: ListMultimap, - body: String, - error: BraintrustError, + statusCode: Int, + headers: ListMultimap, + body: String, + error: BraintrustError, ) : BraintrustServiceException(statusCode, headers, body, error) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt index 095b1fcf..ff46b335 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/errors/UnprocessableEntityException.kt @@ -3,7 +3,7 @@ package com.braintrustdata.api.errors import com.google.common.collect.ListMultimap class UnprocessableEntityException( - headers: ListMultimap, - body: String, - error: BraintrustError, + headers: ListMultimap, + body: String, + error: BraintrustError, ) : BraintrustServiceException(422, headers, body, error) diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt index 0aa463bb..1aaae0af 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Acl.kt @@ -2,47 +2,64 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** - * 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. */ @JsonDeserialize(builder = Acl.Builder::class) @NoAutoDetect -class Acl -private constructor( - private val id: JsonField, - private val objectType: JsonField, - private val objectId: JsonField, - private val userId: JsonField, - private val groupId: JsonField, - private val permission: JsonField, - private val restrictObjectType: JsonField, - private val roleId: JsonField, - private val _objectOrgId: JsonField, - private val created: JsonField, - private val additionalProperties: Map, +class Acl private constructor( + private val id: JsonField, + private val objectType: JsonField, + private val objectId: JsonField, + private val userId: JsonField, + private val groupId: JsonField, + private val permission: JsonField, + private val restrictObjectType: JsonField, + private val roleId: JsonField, + private val _objectOrgId: JsonField, + private val created: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -59,26 +76,33 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(): String? = userId.getNullable("user_id") /** - * 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(): String? = groupId.getNullable("group_id") - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ fun permission(): Permission? = 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(): RestrictObjectType? = - restrictObjectType.getNullable("restrict_object_type") + fun restrictObjectType(): RestrictObjectType? = 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(): String? = roleId.getNullable("role_id") /** The organization the ACL's referred object belongs to */ @@ -88,43 +112,69 @@ private constructor( fun created(): OffsetDateTime? = created.getNullable("created") /** Unique identifier for the acl */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** The object type that the ACL applies to */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType() = objectType /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId() = objectId /** - * 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() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId /** - * 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() = groupId + @JsonProperty("group_id") + @ExcludeMissing + fun _groupId() = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") @ExcludeMissing fun _permission() = permission + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + @JsonProperty("permission") + @ExcludeMissing + fun _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`. */ @JsonProperty("restrict_object_type") @ExcludeMissing fun _restrictObjectType() = restrictObjectType - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("role_id") @ExcludeMissing fun _roleId() = roleId + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + @JsonProperty("role_id") + @ExcludeMissing + fun _roleId() = roleId /** The organization the ACL's referred object belongs to */ - @JsonProperty("_object_org_id") @ExcludeMissing fun __objectOrgId() = _objectOrgId + @JsonProperty("_object_org_id") + @ExcludeMissing + fun __objectOrgId() = _objectOrgId /** Date of acl creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created @JsonAnyGetter @ExcludeMissing @@ -132,63 +182,61 @@ private constructor( fun validate(): Acl = apply { if (!validated) { - id() - objectType() - objectId() - userId() - groupId() - permission() - restrictObjectType() - roleId() - _objectOrgId() - created() - validated = true + id() + objectType() + objectId() + userId() + groupId() + permission() + restrictObjectType() + roleId() + _objectOrgId() + created() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Acl && - this.id == other.id && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.userId == other.userId && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this._objectOrgId == other._objectOrgId && - this.created == other.created && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Acl && + this.id == other.id && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.userId == other.userId && + this.groupId == other.groupId && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.roleId == other.roleId && + this._objectOrgId == other._objectOrgId && + this.created == other.created && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - objectType, - objectId, - userId, - groupId, - permission, - restrictObjectType, - roleId, - _objectOrgId, - created, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + objectType, + objectId, + userId, + groupId, + permission, + restrictObjectType, + roleId, + _objectOrgId, + created, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Acl{id=$id, objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, _objectOrgId=$_objectOrgId, created=$created, additionalProperties=$additionalProperties}" + override fun toString() = "Acl{id=$id, objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, _objectOrgId=$_objectOrgId, created=$created, additionalProperties=$additionalProperties}" companion object { @@ -227,7 +275,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the acl */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) @@ -235,7 +287,9 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** The id of the object the ACL applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) @@ -243,54 +297,67 @@ private constructor( /** The id of the object the ACL applies to */ @JsonProperty("object_id") @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = apply { + this.objectId = objectId + } /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will + * be provided */ fun userId(userId: String) = userId(JsonField.of(userId)) /** - * 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(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } /** - * 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.of(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 */ @JsonProperty("group_id") @ExcludeMissing - 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.of(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 + */ @JsonProperty("permission") @ExcludeMissing - 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.of(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType) = restrictObjectType(JsonField.of(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`. */ @JsonProperty("restrict_object_type") @ExcludeMissing @@ -299,16 +366,20 @@ private constructor( } /** - * 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.of(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 */ @JsonProperty("role_id") @ExcludeMissing - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + fun roleId(roleId: JsonField) = apply { + this.roleId = roleId + } /** The organization the ACL's referred object belongs to */ fun _objectOrgId(_objectOrgId: String) = _objectOrgId(JsonField.of(_objectOrgId)) @@ -326,7 +397,9 @@ private constructor( /** Date of acl creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -342,36 +415,33 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Acl = - Acl( - id, - objectType, - objectId, - userId, - groupId, - permission, - restrictObjectType, - roleId, - _objectOrgId, - created, - additionalProperties.toUnmodifiable(), - ) + fun build(): Acl = Acl( + id, + objectType, + objectId, + userId, + groupId, + permission, + restrictObjectType, + roleId, + _objectOrgId, + created, + additionalProperties.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -434,55 +504,51 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && this.value == other.value + return other is Permission && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -533,49 +599,45 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && this.value == other.value + return other is RestrictObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -638,37 +700,35 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt index d8ebd8bf..8c6f6ecd 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclCreateParams.kt @@ -2,33 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class AclCreateParams constructor( + private val objectId: String, + private val objectType: ObjectType?, + private val groupId: String?, + private val permission: Permission?, + private val restrictObjectType: RestrictObjectType?, + private val roleId: String?, + private val userId: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class AclCreateParams -constructor( - private val objectId: String, - private val objectType: ObjectType?, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val userId: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun objectId(): String = objectId @@ -46,16 +65,16 @@ constructor( fun userId(): String? = userId internal fun getBody(): AclCreateBody { - return AclCreateBody( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalBodyProperties, - ) + return AclCreateBody( + objectId, + objectType, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -63,63 +82,75 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders /** - * 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. */ @JsonDeserialize(builder = AclCreateBody.Builder::class) @NoAutoDetect - class AclCreateBody - internal constructor( - private val objectId: String?, - private val objectType: ObjectType?, - private val groupId: String?, - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val roleId: String?, - private val userId: String?, - private val additionalProperties: Map, + class AclCreateBody internal constructor( + private val objectId: String?, + private val objectType: ObjectType?, + private val groupId: String?, + private val permission: Permission?, + private val restrictObjectType: RestrictObjectType?, + private val roleId: String?, + private val userId: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** The id of the object the ACL applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") + fun objectId(): String? = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + fun objectType(): 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 */ - @JsonProperty("group_id") fun groupId(): String? = groupId + @JsonProperty("group_id") + fun groupId(): String? = groupId - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") fun permission(): Permission? = permission + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + @JsonProperty("permission") + fun permission(): 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`. */ @JsonProperty("restrict_object_type") fun restrictObjectType(): 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 */ - @JsonProperty("role_id") fun roleId(): String? = roleId + @JsonProperty("role_id") + fun roleId(): String? = 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") fun userId(): String? = userId + @JsonProperty("user_id") + fun userId(): String? = userId @JsonAnyGetter @ExcludeMissing @@ -128,40 +159,38 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclCreateBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.userId == other.userId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AclCreateBody && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.groupId == other.groupId && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.roleId == other.roleId && + this.userId == other.userId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + objectId, + objectType, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" + override fun toString() = "AclCreateBody{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalProperties=$additionalProperties}" companion object { @@ -192,28 +221,37 @@ constructor( /** The id of the object the ACL applies to */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = 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 */ @JsonProperty("group_id") - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String) = 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 */ @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Permission) = 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`. */ @JsonProperty("restrict_object_type") fun restrictObjectType(restrictObjectType: RestrictObjectType) = apply { @@ -224,13 +262,19 @@ constructor( * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be * provided */ - @JsonProperty("role_id") fun roleId(roleId: String) = apply { this.roleId = roleId } + @JsonProperty("role_id") + fun roleId(roleId: String) = 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 */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + @JsonProperty("user_id") + fun userId(userId: String) = apply { + this.userId = userId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -246,17 +290,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): AclCreateBody = - AclCreateBody( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalProperties.toUnmodifiable(), - ) + fun build(): AclCreateBody = AclCreateBody( + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalProperties.toUnmodifiable(), + ) } } @@ -267,40 +312,39 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclCreateParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.userId == other.userId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is AclCreateParams && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.groupId == other.groupId && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.roleId == other.roleId && + this.userId == other.userId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + objectId, + objectType, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "AclCreateParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "AclCreateParams{objectId=$objectId, objectType=$objectType, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -337,38 +381,54 @@ constructor( } /** 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 + } /** - * 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 { this.groupId = groupId } + fun groupId(groupId: String) = apply { + this.groupId = groupId + } - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Permission) = apply { this.permission = permission } + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be + * provided + */ + fun permission(permission: Permission) = 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) = 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) = apply { this.roleId = roleId } + fun roleId(roleId: String) = 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) = apply { this.userId = userId } + fun userId(userId: String) = apply { + this.userId = userId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -408,7 +468,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -419,40 +481,38 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): AclCreateParams = - AclCreateParams( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - groupId, - permission, - restrictObjectType, - roleId, - userId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): AclCreateParams = AclCreateParams( + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + groupId, + permission, + restrictObjectType, + roleId, + userId, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -515,55 +575,51 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && this.value == other.value + return other is Permission && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -614,49 +670,45 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun known(): Known = when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && this.value == other.value + return other is RestrictObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -719,37 +771,35 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt index fac04dc9..f829fc7e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class AclDeleteParams -constructor( - private val aclId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class AclDeleteParams constructor( + private val aclId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun aclId(): String = aclId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> aclId - else -> "" - } + return when (index) { + 0 -> aclId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclDeleteParams && - this.aclId == other.aclId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is AclDeleteParams && + this.aclId == other.aclId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - aclId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + aclId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "AclDeleteParams{aclId=$aclId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "AclDeleteParams{aclId=$aclId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** Acl id */ - fun aclId(aclId: String) = apply { this.aclId = aclId } + fun aclId(aclId: String) = apply { + this.aclId = aclId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): AclDeleteParams = - AclDeleteParams( - checkNotNull(aclId) { "`aclId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): AclDeleteParams = AclDeleteParams( + checkNotNull(aclId) { + "`aclId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt index d2994efd..ea26b1d7 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListPage.kt @@ -2,97 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Acl import com.braintrustdata.api.services.blocking.AclService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class AclListPage -private constructor( - private val aclService: AclService, - private val params: AclListParams, - private val response: Response, -) { +class AclListPage private constructor(private val aclService: AclService, private val params: AclListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclListPage && - this.aclService == other.aclService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is AclListPage && + this.aclService == other.aclService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - aclService, - params, - response, - ) + return Objects.hash( + aclService, + params, + response, + ) } - override fun toString() = - "AclListPage{aclService=$aclService, params=$params, response=$response}" + override fun toString() = "AclListPage{aclService=$aclService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): AclListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - AclListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - AclListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + AclListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + AclListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): AclListPage? { - return getNextPageParams()?.let { aclService.list(it) } + return getNextPageParams()?.let { + aclService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(aclService: AclService, params: AclListParams, response: Response) = - AclListPage( - aclService, - params, - response, - ) + fun of(aclService: AclService, params: AclListParams, response: Response) = AclListPage( + aclService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -100,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "AclListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "AclListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -153,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: AclListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: AclListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt index 49b375f0..cbcadf43 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListPageAsync.kt @@ -2,99 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.AclServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Acl +import com.braintrustdata.api.services.async.AclServiceAsync -class AclListPageAsync -private constructor( - private val aclService: AclServiceAsync, - private val params: AclListParams, - private val response: Response, -) { +class AclListPageAsync private constructor(private val aclService: AclServiceAsync, private val params: AclListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclListPageAsync && - this.aclService == other.aclService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is AclListPageAsync && + this.aclService == other.aclService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - aclService, - params, - response, - ) + return Objects.hash( + aclService, + params, + response, + ) } - override fun toString() = - "AclListPageAsync{aclService=$aclService, params=$params, response=$response}" + override fun toString() = "AclListPageAsync{aclService=$aclService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): AclListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - AclListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - AclListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + AclListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + AclListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): AclListPageAsync? { - return getNextPageParams()?.let { aclService.list(it) } + return getNextPageParams()?.let { + aclService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(aclService: AclServiceAsync, params: AclListParams, response: Response) = - AclListPageAsync( - aclService, - params, - response, - ) + fun of(aclService: AclServiceAsync, params: AclListParams, response: Response) = AclListPageAsync( + aclService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -102,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "AclListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "AclListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -155,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: AclListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: AclListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt index 3311b003..2f9eb1b6 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclListParams.kt @@ -2,36 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class AclListParams constructor( + private val objectId: String, + private val objectType: ObjectType?, + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class AclListParams -constructor( - private val objectId: String, - private val objectType: ObjectType?, - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun objectId(): String = objectId @@ -47,15 +61,27 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.objectId.let { params.put("object_id", listOf(it.toString())) } - this.objectType.let { params.put("object_type", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.objectId.let { + params.put("object_id", listOf(it.toString())) + } + this.objectType.let { + params.put("object_type", listOf(it.toString())) + } + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -65,36 +91,35 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclListParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is AclListParams && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - endingBefore, - ids, - limit, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + objectId, + objectType, + endingBefore, + ids, + limit, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "AclListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -127,49 +152,65 @@ constructor( } /** 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** * 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -209,35 +250,36 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): AclListParams = - AclListParams( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - endingBefore, - ids, - limit, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): AclListParams = AclListParams( + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + endingBefore, + ids, + limit, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -300,102 +342,94 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -412,38 +446,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt deleted file mode 100755 index fc8e9813..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclObjectType.kt +++ /dev/null @@ -1,120 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator - -class AclObjectType -@JsonCreator -private constructor( - private val value: JsonField, -) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val ORGANIZATION = AclObjectType(JsonField.of("organization")) - - val PROJECT = AclObjectType(JsonField.of("project")) - - val EXPERIMENT = AclObjectType(JsonField.of("experiment")) - - val DATASET = AclObjectType(JsonField.of("dataset")) - - val PROMPT = AclObjectType(JsonField.of("prompt")) - - val PROMPT_SESSION = AclObjectType(JsonField.of("prompt_session")) - - val GROUP = AclObjectType(JsonField.of("group")) - - val ROLE = AclObjectType(JsonField.of("role")) - - val ORG_MEMBER = AclObjectType(JsonField.of("org_member")) - - val PROJECT_LOG = AclObjectType(JsonField.of("project_log")) - - val ORG_PROJECT = AclObjectType(JsonField.of("org_project")) - - fun of(value: String) = AclObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown AclObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt index 86a4bf63..af65b544 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/AclRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class AclRetrieveParams -constructor( - private val aclId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class AclRetrieveParams constructor(private val aclId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun aclId(): String = aclId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> aclId - else -> "" - } + return when (index) { + 0 -> aclId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AclRetrieveParams && - this.aclId == other.aclId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is AclRetrieveParams && + this.aclId == other.aclId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - aclId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + aclId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "AclRetrieveParams{aclId=$aclId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "AclRetrieveParams{aclId=$aclId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** Acl id */ - fun aclId(aclId: String) = apply { this.aclId = aclId } + fun aclId(aclId: String) = apply { + this.aclId = aclId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): AclRetrieveParams = - AclRetrieveParams( - checkNotNull(aclId) { "`aclId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): AclRetrieveParams = AclRetrieveParams( + checkNotNull(aclId) { + "`aclId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt index 87aee8eb..5899204a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKey.kt @@ -2,30 +2,48 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ApiKey.Builder::class) @NoAutoDetect -class ApiKey -private constructor( - private val id: JsonField, - private val created: JsonField, - private val name: JsonField, - private val previewName: JsonField, - private val userId: JsonField, - private val orgId: JsonField, - private val additionalProperties: Map, +class ApiKey private constructor( + private val id: JsonField, + private val created: JsonField, + private val name: JsonField, + private val previewName: JsonField, + private val userId: JsonField, + private val orgId: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -50,21 +68,33 @@ private constructor( fun orgId(): String? = orgId.getNullable("org_id") /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** Date of api key creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Name of the api key */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name - @JsonProperty("preview_name") @ExcludeMissing fun _previewName() = previewName + @JsonProperty("preview_name") + @ExcludeMissing + fun _previewName() = previewName /** Unique identifier for the user */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId() = orgId @JsonAnyGetter @ExcludeMissing @@ -72,51 +102,49 @@ private constructor( fun validate(): ApiKey = apply { if (!validated) { - id() - created() - name() - previewName() - userId() - orgId() - validated = true + id() + created() + name() + previewName() + userId() + orgId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKey && - this.id == other.id && - this.created == other.created && - this.name == other.name && - this.previewName == other.previewName && - this.userId == other.userId && - this.orgId == other.orgId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ApiKey && + this.id == other.id && + this.created == other.created && + this.name == other.name && + this.previewName == other.previewName && + this.userId == other.userId && + this.orgId == other.orgId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - created, - name, - previewName, - userId, - orgId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + created, + name, + previewName, + userId, + orgId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ApiKey{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, additionalProperties=$additionalProperties}" + override fun toString() = "ApiKey{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, additionalProperties=$additionalProperties}" companion object { @@ -147,7 +175,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** Date of api key creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -155,7 +187,9 @@ private constructor( /** Date of api key creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) @@ -163,13 +197,17 @@ private constructor( /** Name of the api key */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) @JsonProperty("preview_name") @ExcludeMissing - fun previewName(previewName: JsonField) = apply { this.previewName = previewName } + fun previewName(previewName: JsonField) = apply { + this.previewName = previewName + } /** Unique identifier for the user */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -177,7 +215,9 @@ private constructor( /** Unique identifier for the user */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -185,7 +225,9 @@ private constructor( /** Unique identifier for the organization */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = apply { + this.orgId = orgId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -201,15 +243,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ApiKey = - ApiKey( - id, - created, - name, - previewName, - userId, - orgId, - additionalProperties.toUnmodifiable(), - ) + fun build(): ApiKey = ApiKey( + id, + created, + name, + previewName, + userId, + orgId, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt deleted file mode 100755 index 14568b34..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateParams.kt +++ /dev/null @@ -1,274 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -class ApiKeyCreateParams -constructor( - private val name: String, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, -) { - - fun name(): String = name - - fun orgName(): String? = orgName - - internal fun getBody(): ApiKeyCreateBody { - return ApiKeyCreateBody( - name, - orgName, - additionalBodyProperties, - ) - } - - internal fun getQueryParams(): Map> = additionalQueryParams - - internal fun getHeaders(): Map> = additionalHeaders - - @JsonDeserialize(builder = ApiKeyCreateBody.Builder::class) - @NoAutoDetect - class ApiKeyCreateBody - internal constructor( - private val name: String?, - private val orgName: String?, - private val additionalProperties: Map, - ) { - - private var hashCode: Int = 0 - - /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") fun name(): String? = name - - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. - */ - @JsonProperty("org_name") fun orgName(): String? = orgName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyCreateBody && - this.name == other.name && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ApiKeyCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: String? = null - private var orgName: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(apiKeyCreateBody: ApiKeyCreateBody) = apply { - this.name = apiKeyCreateBody.name - this.orgName = apiKeyCreateBody.orgName - additionalProperties(apiKeyCreateBody.additionalProperties) - } - - /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") fun name(name: String) = 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. - */ - @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ApiKeyCreateBody = - ApiKeyCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, - additionalProperties.toUnmodifiable(), - ) - } - } - - fun _additionalQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyCreateParams && - this.name == other.name && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int { - return Objects.hash( - name, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) - } - - override fun toString() = - "ApiKeyCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" - - fun toBuilder() = Builder().from(this) - - companion object { - - fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var name: String? = null - private var orgName: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = apply { - this.name = apiKeyCreateParams.name - this.orgName = apiKeyCreateParams.orgName - additionalQueryParams(apiKeyCreateParams.additionalQueryParams) - additionalHeaders(apiKeyCreateParams.additionalHeaders) - additionalBodyProperties(apiKeyCreateParams.additionalBodyProperties) - } - - /** Name of the api key. Does not have to be unique */ - fun name(name: String) = apply { this.name = name } - - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the API key belongs in. - */ - fun orgName(orgName: String) = apply { this.orgName = orgName } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) - } - - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) - } - - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) - } - - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } - - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ApiKeyCreateParams = - ApiKeyCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponse.kt deleted file mode 100755 index 7d2b78a3..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponse.kt +++ /dev/null @@ -1,236 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects - -@JsonDeserialize(builder = ApiKeyCreateResponse.Builder::class) -@NoAutoDetect -class ApiKeyCreateResponse -private constructor( - private val id: JsonField, - private val created: JsonField, - private val name: JsonField, - private val previewName: JsonField, - private val userId: JsonField, - private val orgId: JsonField, - private val key: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the api key */ - fun id(): String = id.getRequired("id") - - /** Date of api key creation */ - fun created(): OffsetDateTime? = created.getNullable("created") - - /** Name of the api key */ - fun name(): String = name.getRequired("name") - - fun previewName(): String = previewName.getRequired("preview_name") - - /** Unique identifier for the user */ - fun userId(): String? = userId.getNullable("user_id") - - /** Unique identifier for the organization */ - fun orgId(): String? = orgId.getNullable("org_id") - - /** The raw API key. It will only be exposed this one time */ - fun key(): String = key.getRequired("key") - - /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** Date of api key creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** Name of the api key */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("preview_name") @ExcludeMissing fun _previewName() = previewName - - /** Unique identifier for the user */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId - - /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - - /** The raw API key. It will only be exposed this one time */ - @JsonProperty("key") @ExcludeMissing fun _key() = key - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ApiKeyCreateResponse = apply { - if (!validated) { - id() - created() - name() - previewName() - userId() - orgId() - key() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyCreateResponse && - this.id == other.id && - this.created == other.created && - this.name == other.name && - this.previewName == other.previewName && - this.userId == other.userId && - this.orgId == other.orgId && - this.key == other.key && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - created, - name, - previewName, - userId, - orgId, - key, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ApiKeyCreateResponse{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, key=$key, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var previewName: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var key: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(apiKeyCreateResponse: ApiKeyCreateResponse) = apply { - this.id = apiKeyCreateResponse.id - this.created = apiKeyCreateResponse.created - this.name = apiKeyCreateResponse.name - this.previewName = apiKeyCreateResponse.previewName - this.userId = apiKeyCreateResponse.userId - this.orgId = apiKeyCreateResponse.orgId - this.key = apiKeyCreateResponse.key - additionalProperties(apiKeyCreateResponse.additionalProperties) - } - - /** Unique identifier for the api key */ - fun id(id: String) = id(JsonField.of(id)) - - /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** Date of api key creation */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** Date of api key creation */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** Name of the api key */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the api key */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun previewName(previewName: String) = previewName(JsonField.of(previewName)) - - @JsonProperty("preview_name") - @ExcludeMissing - fun previewName(previewName: JsonField) = apply { this.previewName = previewName } - - /** Unique identifier for the user */ - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** Unique identifier for the user */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } - - /** Unique identifier for the organization */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - - /** Unique identifier for the organization */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - - /** 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 */ - @JsonProperty("key") - @ExcludeMissing - fun key(key: JsonField) = apply { this.key = key } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ApiKeyCreateResponse = - ApiKeyCreateResponse( - id, - created, - name, - previewName, - userId, - orgId, - key, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt deleted file mode 100755 index 338b0aca..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParams.kt +++ /dev/null @@ -1,153 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* -import java.util.Objects - -class ApiKeyDeleteParams -constructor( - private val apiKeyId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, -) { - - fun apiKeyId(): String = apiKeyId - - internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } - } - - internal fun getQueryParams(): Map> = additionalQueryParams - - internal fun getHeaders(): Map> = additionalHeaders - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } - } - - fun _additionalQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyDeleteParams && - this.apiKeyId == other.apiKeyId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int { - return Objects.hash( - apiKeyId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) - } - - override fun toString() = - "ApiKeyDeleteParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" - - fun toBuilder() = Builder().from(this) - - companion object { - - fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var apiKeyId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - internal fun from(apiKeyDeleteParams: ApiKeyDeleteParams) = apply { - this.apiKeyId = apiKeyDeleteParams.apiKeyId - additionalQueryParams(apiKeyDeleteParams.additionalQueryParams) - additionalHeaders(apiKeyDeleteParams.additionalHeaders) - additionalBodyProperties(apiKeyDeleteParams.additionalBodyProperties) - } - - /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) - } - - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) - } - - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) - } - - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } - - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ApiKeyDeleteParams = - ApiKeyDeleteParams( - checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt deleted file mode 100755 index 6544fc5a..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPage.kt +++ /dev/null @@ -1,173 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.blocking.ApiKeyService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -class ApiKeyListPage -private constructor( - private val apiKeysService: ApiKeyService, - private val params: ApiKeyListParams, - private val response: Response, -) { - - fun response(): Response = response - - fun objects(): List = response().objects() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyListPage && - this.apiKeysService == other.apiKeysService && - this.params == other.params && - this.response == other.response - } - - override fun hashCode(): Int { - return Objects.hash( - apiKeysService, - params, - response, - ) - } - - override fun toString() = - "ApiKeyListPage{apiKeysService=$apiKeysService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !objects().isEmpty() - } - - fun getNextPageParams(): ApiKeyListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() - } - } - - fun getNextPage(): ApiKeyListPage? { - return getNextPageParams()?.let { apiKeysService.list(it) } - } - - fun autoPager(): AutoPager = AutoPager(this) - - companion object { - - fun of(apiKeysService: ApiKeyService, params: ApiKeyListParams, response: Response) = - ApiKeyListPage( - apiKeysService, - params, - response, - ) - } - - @JsonDeserialize(builder = Response.Builder::class) - @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun objects(): List = objects.getNullable("objects") ?: listOf() - - @JsonProperty("objects") fun _objects(): JsonField>? = objects - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) - } - - override fun toString() = - "ApiKeyListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var objects: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } - - fun objects(objects: List) = objects(JsonField.of(objects)) - - @JsonProperty("objects") - fun objects(objects: JsonField>) = apply { this.objects = objects } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun build() = Response(objects, additionalProperties.toUnmodifiable()) - } - } - - class AutoPager - constructor( - private val firstPage: ApiKeyListPage, - ) : Sequence { - - 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() ?: break - index = 0 - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt deleted file mode 100755 index 8a6b6ce2..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListPageAsync.kt +++ /dev/null @@ -1,175 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.ApiKeyServiceAsync -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.FlowCollector - -class ApiKeyListPageAsync -private constructor( - private val apiKeysService: ApiKeyServiceAsync, - private val params: ApiKeyListParams, - private val response: Response, -) { - - fun response(): Response = response - - fun objects(): List = response().objects() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyListPageAsync && - this.apiKeysService == other.apiKeysService && - this.params == other.params && - this.response == other.response - } - - override fun hashCode(): Int { - return Objects.hash( - apiKeysService, - params, - response, - ) - } - - override fun toString() = - "ApiKeyListPageAsync{apiKeysService=$apiKeysService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !objects().isEmpty() - } - - fun getNextPageParams(): ApiKeyListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ApiKeyListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - ApiKeyListParams.builder().from(params).startingAfter(objects().last().id()).build() - } - } - - suspend fun getNextPage(): ApiKeyListPageAsync? { - return getNextPageParams()?.let { apiKeysService.list(it) } - } - - fun autoPager(): AutoPager = AutoPager(this) - - companion object { - - fun of(apiKeysService: ApiKeyServiceAsync, params: ApiKeyListParams, response: Response) = - ApiKeyListPageAsync( - apiKeysService, - params, - response, - ) - } - - @JsonDeserialize(builder = Response.Builder::class) - @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun objects(): List = objects.getNullable("objects") ?: listOf() - - @JsonProperty("objects") fun _objects(): JsonField>? = objects - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Response = apply { - if (!validated) { - objects().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) - } - - override fun toString() = - "ApiKeyListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var objects: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(page: Response) = apply { - this.objects = page.objects - this.additionalProperties.putAll(page.additionalProperties) - } - - fun objects(objects: List) = objects(JsonField.of(objects)) - - @JsonProperty("objects") - fun objects(objects: JsonField>) = apply { this.objects = objects } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun build() = Response(objects, additionalProperties.toUnmodifiable()) - } - } - - class AutoPager - constructor( - private val firstPage: ApiKeyListPageAsync, - ) : Flow { - - override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt deleted file mode 100755 index 55d4e747..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyListParams.kt +++ /dev/null @@ -1,358 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -class ApiKeyListParams -constructor( - private val apiKeyName: String?, - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, -) { - - fun apiKeyName(): String? = apiKeyName - - fun endingBefore(): String? = endingBefore - - fun ids(): Ids? = ids - - fun limit(): Long? = limit - - fun orgName(): String? = orgName - - fun startingAfter(): String? = startingAfter - - internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.apiKeyName?.let { params.put("api_key_name", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() - } - - internal fun getHeaders(): Map> = additionalHeaders - - fun _additionalQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyListParams && - this.apiKeyName == other.apiKeyName && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int { - return Objects.hash( - apiKeyName, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) - } - - override fun toString() = - "ApiKeyListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" - - fun toBuilder() = Builder().from(this) - - companion object { - - fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var apiKeyName: String? = null - private var endingBefore: String? = null - private var ids: Ids? = null - private var limit: Long? = null - private var orgName: String? = null - private var startingAfter: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - internal fun from(apiKeyListParams: ApiKeyListParams) = apply { - this.apiKeyName = apiKeyListParams.apiKeyName - this.endingBefore = apiKeyListParams.endingBefore - this.ids = apiKeyListParams.ids - this.limit = apiKeyListParams.limit - this.orgName = apiKeyListParams.orgName - this.startingAfter = apiKeyListParams.startingAfter - additionalQueryParams(apiKeyListParams.additionalQueryParams) - additionalHeaders(apiKeyListParams.additionalHeaders) - additionalBodyProperties(apiKeyListParams.additionalBodyProperties) - } - - /** Name of the api_key to search for */ - fun apiKeyName(apiKeyName: String) = apply { this.apiKeyName = apiKeyName } - - /** - * Pagination cursor id. - * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ - fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } - - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ - fun ids(ids: Ids) = apply { this.ids = ids } - - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ - fun ids(string: String) = apply { this.ids = Ids.ofString(string) } - - /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times - */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } - - /** Limit the number of objects to return */ - fun limit(limit: Long) = apply { this.limit = limit } - - /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } - - /** - * Pagination cursor id. - * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of - * `starting_after` and `ending_before` - */ - fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) - } - - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) - } - - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) - } - - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } - - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ApiKeyListParams = - ApiKeyListParams( - apiKeyName, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Ids.Deserializer::class) - @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun string(): String? = string - - fun strings(): List? = strings - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - fun ofString(string: String) = Ids(string = string) - - fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParams.kt index e296dc9e..57396219 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParams.kt @@ -2,24 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ApiKeyResourceCreateParams constructor( + private val name: String, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ApiKeyResourceCreateParams -constructor( - private val name: String, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -27,11 +50,11 @@ constructor( fun orgName(): String? = orgName internal fun getBody(): ApiKeyResourceCreateBody { - return ApiKeyResourceCreateBody( - name, - orgName, - additionalBodyProperties, - ) + return ApiKeyResourceCreateBody( + name, + orgName, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -40,24 +63,21 @@ constructor( @JsonDeserialize(builder = ApiKeyResourceCreateBody.Builder::class) @NoAutoDetect - class ApiKeyResourceCreateBody - internal constructor( - private val name: String?, - private val orgName: String?, - private val additionalProperties: Map, - ) { + class ApiKeyResourceCreateBody internal constructor(private val name: String?, private val orgName: String?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = 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") fun orgName(): String? = orgName + @JsonProperty("org_name") + fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -66,30 +86,28 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyResourceCreateBody && - this.name == other.name && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ApiKeyResourceCreateBody && + this.name == other.name && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ApiKeyResourceCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "ApiKeyResourceCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { @@ -109,15 +127,20 @@ constructor( } /** Name of the api key. Does not have to be unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = 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. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -133,12 +156,13 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ApiKeyResourceCreateBody = - ApiKeyResourceCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): ApiKeyResourceCreateBody = ApiKeyResourceCreateBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -149,30 +173,29 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyResourceCreateParams && - this.name == other.name && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ApiKeyResourceCreateParams && + this.name == other.name && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ApiKeyResourceCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ApiKeyResourceCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -199,14 +222,18 @@ constructor( } /** Name of the api key. Does not have to be unique */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = 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) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -246,7 +273,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -257,18 +286,18 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ApiKeyResourceCreateParams = - ApiKeyResourceCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ApiKeyResourceCreateParams = ApiKeyResourceCreateParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParams.kt index e9f32cd5..cf151d1c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ApiKeyResourceDeleteParams -constructor( - private val apiKeyId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ApiKeyResourceDeleteParams constructor( + private val apiKeyId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun apiKeyId(): String = apiKeyId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } + return when (index) { + 0 -> apiKeyId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyResourceDeleteParams && - this.apiKeyId == other.apiKeyId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ApiKeyResourceDeleteParams && + this.apiKeyId == other.apiKeyId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - apiKeyId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + apiKeyId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ApiKeyResourceDeleteParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ApiKeyResourceDeleteParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } + fun apiKeyId(apiKeyId: String) = apply { + this.apiKeyId = apiKeyId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ApiKeyResourceDeleteParams = - ApiKeyResourceDeleteParams( - checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ApiKeyResourceDeleteParams = ApiKeyResourceDeleteParams( + checkNotNull(apiKeyId) { + "`apiKeyId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPage.kt index c0922f44..05364f52 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPage.kt @@ -2,107 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.services.blocking.ApiKeyResourceService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class ApiKeyResourceListPage -private constructor( - private val apiKeyResourceService: ApiKeyResourceService, - private val params: ApiKeyResourceListParams, - private val response: Response, -) { +class ApiKeyResourceListPage private constructor(private val apiKeyResourceService: ApiKeyResourceService, private val params: ApiKeyResourceListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyResourceListPage && - this.apiKeyResourceService == other.apiKeyResourceService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ApiKeyResourceListPage && + this.apiKeyResourceService == other.apiKeyResourceService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - apiKeyResourceService, - params, - response, - ) + return Objects.hash( + apiKeyResourceService, + params, + response, + ) } - override fun toString() = - "ApiKeyResourceListPage{apiKeyResourceService=$apiKeyResourceService, params=$params, response=$response}" + override fun toString() = "ApiKeyResourceListPage{apiKeyResourceService=$apiKeyResourceService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ApiKeyResourceListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ApiKeyResourceListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - } else { - ApiKeyResourceListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ApiKeyResourceListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ApiKeyResourceListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): ApiKeyResourceListPage? { - return getNextPageParams()?.let { apiKeyResourceService.list(it) } + return getNextPageParams()?.let { + apiKeyResourceService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - apiKeyResourceService: ApiKeyResourceService, - params: ApiKeyResourceListParams, - response: Response - ) = - ApiKeyResourceListPage( - apiKeyResourceService, - params, - response, - ) + fun of(apiKeyResourceService: ApiKeyResourceService, params: ApiKeyResourceListParams, response: Response) = ApiKeyResourceListPage( + apiKeyResourceService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -110,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ApiKeyResourceListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ApiKeyResourceListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -163,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ApiKeyResourceListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: ApiKeyResourceListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPageAsync.kt index ceba5b02..daabd2c1 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListPageAsync.kt @@ -2,109 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.ApiKeyResourceServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.ApiKey +import com.braintrustdata.api.services.async.ApiKeyResourceServiceAsync -class ApiKeyResourceListPageAsync -private constructor( - private val apiKeyResourceService: ApiKeyResourceServiceAsync, - private val params: ApiKeyResourceListParams, - private val response: Response, -) { +class ApiKeyResourceListPageAsync private constructor(private val apiKeyResourceService: ApiKeyResourceServiceAsync, private val params: ApiKeyResourceListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyResourceListPageAsync && - this.apiKeyResourceService == other.apiKeyResourceService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ApiKeyResourceListPageAsync && + this.apiKeyResourceService == other.apiKeyResourceService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - apiKeyResourceService, - params, - response, - ) + return Objects.hash( + apiKeyResourceService, + params, + response, + ) } - override fun toString() = - "ApiKeyResourceListPageAsync{apiKeyResourceService=$apiKeyResourceService, params=$params, response=$response}" + override fun toString() = "ApiKeyResourceListPageAsync{apiKeyResourceService=$apiKeyResourceService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ApiKeyResourceListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ApiKeyResourceListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - } else { - ApiKeyResourceListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ApiKeyResourceListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ApiKeyResourceListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): ApiKeyResourceListPageAsync? { - return getNextPageParams()?.let { apiKeyResourceService.list(it) } + return getNextPageParams()?.let { + apiKeyResourceService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - apiKeyResourceService: ApiKeyResourceServiceAsync, - params: ApiKeyResourceListParams, - response: Response - ) = - ApiKeyResourceListPageAsync( - apiKeyResourceService, - params, - response, - ) + fun of(apiKeyResourceService: ApiKeyResourceServiceAsync, params: ApiKeyResourceListParams, response: Response) = ApiKeyResourceListPageAsync( + apiKeyResourceService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -112,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ApiKeyResourceListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ApiKeyResourceListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -165,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ApiKeyResourceListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: ApiKeyResourceListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParams.kt index 65db9272..15d6a7a5 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParams.kt @@ -2,33 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ApiKeyResourceListParams constructor( + private val apiKeyName: String?, + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class ApiKeyResourceListParams -constructor( - private val apiKeyName: String?, - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun apiKeyName(): String? = apiKeyName @@ -44,15 +61,27 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.apiKeyName?.let { params.put("api_key_name", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.apiKeyName?.let { + params.put("api_key_name", listOf(it.toString())) + } + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -62,36 +91,35 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyResourceListParams && - this.apiKeyName == other.apiKeyName && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ApiKeyResourceListParams && + this.apiKeyName == other.apiKeyName && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - apiKeyName, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + apiKeyName, + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ApiKeyResourceListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ApiKeyResourceListParams{apiKeyName=$apiKeyName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -124,49 +152,65 @@ constructor( } /** Name of the api_key to search for */ - fun apiKeyName(apiKeyName: String) = apply { this.apiKeyName = apiKeyName } + fun apiKeyName(apiKeyName: String) = apply { + this.apiKeyName = apiKeyName + } /** * 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -206,82 +250,77 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): ApiKeyResourceListParams = - ApiKeyResourceListParams( - apiKeyName, - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): ApiKeyResourceListParams = ApiKeyResourceListParams( + apiKeyName, + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -298,38 +337,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParams.kt index 57b73408..9ce9d6ca 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ApiKeyResourceRetrieveParams -constructor( - private val apiKeyId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class ApiKeyResourceRetrieveParams constructor(private val apiKeyId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun apiKeyId(): String = apiKeyId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } + return when (index) { + 0 -> apiKeyId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyResourceRetrieveParams && - this.apiKeyId == other.apiKeyId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ApiKeyResourceRetrieveParams && + this.apiKeyId == other.apiKeyId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - apiKeyId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + apiKeyId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ApiKeyResourceRetrieveParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ApiKeyResourceRetrieveParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } + fun apiKeyId(apiKeyId: String) = apply { + this.apiKeyId = apiKeyId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): ApiKeyResourceRetrieveParams = - ApiKeyResourceRetrieveParams( - checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): ApiKeyResourceRetrieveParams = ApiKeyResourceRetrieveParams( + checkNotNull(apiKeyId) { + "`apiKeyId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt deleted file mode 100755 index 9e1434b2..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParams.kt +++ /dev/null @@ -1,149 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* -import java.util.Objects - -class ApiKeyRetrieveParams -constructor( - private val apiKeyId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, -) { - - fun apiKeyId(): String = apiKeyId - - internal fun getQueryParams(): Map> = additionalQueryParams - - internal fun getHeaders(): Map> = additionalHeaders - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> apiKeyId - else -> "" - } - } - - fun _additionalQueryParams(): Map> = additionalQueryParams - - fun _additionalHeaders(): Map> = additionalHeaders - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ApiKeyRetrieveParams && - this.apiKeyId == other.apiKeyId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int { - return Objects.hash( - apiKeyId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) - } - - override fun toString() = - "ApiKeyRetrieveParams{apiKeyId=$apiKeyId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" - - fun toBuilder() = Builder().from(this) - - companion object { - - fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var apiKeyId: String? = null - private var additionalQueryParams: MutableMap> = mutableMapOf() - private var additionalHeaders: MutableMap> = mutableMapOf() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - internal fun from(apiKeyRetrieveParams: ApiKeyRetrieveParams) = apply { - this.apiKeyId = apiKeyRetrieveParams.apiKeyId - additionalQueryParams(apiKeyRetrieveParams.additionalQueryParams) - additionalHeaders(apiKeyRetrieveParams.additionalHeaders) - additionalBodyProperties(apiKeyRetrieveParams.additionalBodyProperties) - } - - /** ApiKey id */ - fun apiKeyId(apiKeyId: String) = apply { this.apiKeyId = apiKeyId } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllQueryParams(additionalQueryParams) - } - - fun putQueryParam(name: String, value: String) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putQueryParams(name: String, values: Iterable) = apply { - this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllQueryParams(additionalQueryParams: Map>) = apply { - additionalQueryParams.forEach(this::putQueryParams) - } - - fun removeQueryParam(name: String) = apply { - this.additionalQueryParams.put(name, mutableListOf()) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllHeaders(additionalHeaders) - } - - fun putHeader(name: String, value: String) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) - } - - fun putHeaders(name: String, values: Iterable) = apply { - this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) - } - - fun putAllHeaders(additionalHeaders: Map>) = apply { - additionalHeaders.forEach(this::putHeaders) - } - - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - this.additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ApiKeyRetrieveParams = - ApiKeyRetrieveParams( - checkNotNull(apiKeyId) { "`apiKeyId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateAcl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateAcl.kt deleted file mode 100755 index 9157b382..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateAcl.kt +++ /dev/null @@ -1,611 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -/** - * An ACL grants a certain permission or role to a certain user or group on an object. - * - * ACLs are inherited across the object hierarchy. So for example, if a user has read permissions on - * a project, they will also have read permissions on any experiment, dataset, etc. created within - * that project. - * - * To restrict a grant to a particular sub-object, you may specify `restrict_object_type` in the - * ACL, as part of a direct permission grant or as part of a role. - */ -@JsonDeserialize(builder = CreateAcl.Builder::class) -@NoAutoDetect -class CreateAcl -private constructor( - private val objectType: JsonField, - private val objectId: JsonField, - private val userId: JsonField, - private val groupId: JsonField, - private val permission: JsonField, - private val restrictObjectType: JsonField, - private val roleId: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The object type that the ACL applies to */ - fun objectType(): ObjectType? = objectType.getNullable("object_type") - - /** The id of the object the ACL applies to */ - fun objectId(): String = objectId.getRequired("object_id") - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided - */ - fun userId(): String? = userId.getNullable("user_id") - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided - */ - fun groupId(): String? = groupId.getNullable("group_id") - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(): Permission? = permission.getNullable("permission") - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - fun restrictObjectType(): RestrictObjectType? = - restrictObjectType.getNullable("restrict_object_type") - - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun roleId(): String? = roleId.getNullable("role_id") - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType - - /** The id of the object the ACL applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided - */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId() = groupId - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") @ExcludeMissing fun _permission() = permission - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - @JsonProperty("restrict_object_type") - @ExcludeMissing - fun _restrictObjectType() = restrictObjectType - - /** Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("role_id") @ExcludeMissing fun _roleId() = roleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreateAcl = apply { - if (!validated) { - objectType() - objectId() - userId() - groupId() - permission() - restrictObjectType() - roleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateAcl && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.userId == other.userId && - this.groupId == other.groupId && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.roleId == other.roleId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - userId, - groupId, - permission, - restrictObjectType, - roleId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateAcl{objectType=$objectType, objectId=$objectId, userId=$userId, groupId=$groupId, permission=$permission, restrictObjectType=$restrictObjectType, roleId=$roleId, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var groupId: JsonField = JsonMissing.of() - private var permission: JsonField = JsonMissing.of() - private var restrictObjectType: JsonField = JsonMissing.of() - private var roleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createAcl: CreateAcl) = apply { - this.objectType = createAcl.objectType - this.objectId = createAcl.objectId - this.userId = createAcl.userId - this.groupId = createAcl.groupId - this.permission = createAcl.permission - this.restrictObjectType = createAcl.restrictObjectType - this.roleId = createAcl.roleId - additionalProperties(createAcl.additionalProperties) - } - - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } - - /** The id of the object the ACL applies to */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** The id of the object the ACL applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** - * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - fun groupId(groupId: String) = groupId(JsonField.of(groupId)) - - /** - * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be - * provided - */ - @JsonProperty("group_id") - @ExcludeMissing - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - fun permission(permission: Permission) = permission(JsonField.of(permission)) - - /** Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided */ - @JsonProperty("permission") - @ExcludeMissing - fun permission(permission: JsonField) = apply { this.permission = permission } - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - fun restrictObjectType(restrictObjectType: RestrictObjectType) = - restrictObjectType(JsonField.of(restrictObjectType)) - - /** - * When setting a permission directly, optionally restricts the permission grant to just the - * specified object type. Cannot be set alongside a `role_id`. - */ - @JsonProperty("restrict_object_type") - @ExcludeMissing - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - fun roleId(roleId: String) = roleId(JsonField.of(roleId)) - - /** - * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided - */ - @JsonProperty("role_id") - @ExcludeMissing - fun roleId(roleId: JsonField) = apply { this.roleId = roleId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreateAcl = - CreateAcl( - objectType, - objectId, - userId, - groupId, - permission, - restrictObjectType, - roleId, - additionalProperties.toUnmodifiable(), - ) - } - - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val ORGANIZATION = ObjectType(JsonField.of("organization")) - - val PROJECT = ObjectType(JsonField.of("project")) - - val EXPERIMENT = ObjectType(JsonField.of("experiment")) - - val DATASET = ObjectType(JsonField.of("dataset")) - - val PROMPT = ObjectType(JsonField.of("prompt")) - - val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) - - val GROUP = ObjectType(JsonField.of("group")) - - val ROLE = ObjectType(JsonField.of("role")) - - val ORG_MEMBER = ObjectType(JsonField.of("org_member")) - - val PROJECT_LOG = ObjectType(JsonField.of("project_log")) - - val ORG_PROJECT = ObjectType(JsonField.of("org_project")) - - fun of(value: String) = ObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Permission && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val CREATE = Permission(JsonField.of("create")) - - val READ = Permission(JsonField.of("read")) - - val UPDATE = Permission(JsonField.of("update")) - - val DELETE = Permission(JsonField.of("delete")) - - val CREATE_ACLS = Permission(JsonField.of("create_acls")) - - val READ_ACLS = Permission(JsonField.of("read_acls")) - - val UPDATE_ACLS = Permission(JsonField.of("update_acls")) - - val DELETE_ACLS = Permission(JsonField.of("delete_acls")) - - fun of(value: String) = Permission(JsonField.of(value)) - } - - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - enum class Value { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RestrictObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val ORGANIZATION = RestrictObjectType(JsonField.of("organization")) - - val PROJECT = RestrictObjectType(JsonField.of("project")) - - val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) - - val DATASET = RestrictObjectType(JsonField.of("dataset")) - - val PROMPT = RestrictObjectType(JsonField.of("prompt")) - - val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) - - val GROUP = RestrictObjectType(JsonField.of("group")) - - val ROLE = RestrictObjectType(JsonField.of("role")) - - val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) - - val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) - - val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) - - fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt index 8f855251..96387d22 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateApiKeyOutput.kt @@ -2,31 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = CreateApiKeyOutput.Builder::class) @NoAutoDetect -class CreateApiKeyOutput -private constructor( - private val id: JsonField, - private val created: JsonField, - private val name: JsonField, - private val previewName: JsonField, - private val userId: JsonField, - private val orgId: JsonField, - private val key: JsonField, - private val additionalProperties: Map, +class CreateApiKeyOutput private constructor( + private val id: JsonField, + private val created: JsonField, + private val name: JsonField, + private val previewName: JsonField, + private val userId: JsonField, + private val orgId: JsonField, + private val key: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -54,24 +72,38 @@ private constructor( fun key(): String = key.getRequired("key") /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** Date of api key creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Name of the api key */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name - @JsonProperty("preview_name") @ExcludeMissing fun _previewName() = previewName + @JsonProperty("preview_name") + @ExcludeMissing + fun _previewName() = previewName /** Unique identifier for the user */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId() = orgId /** The raw API key. It will only be exposed this one time */ - @JsonProperty("key") @ExcludeMissing fun _key() = key + @JsonProperty("key") + @ExcludeMissing + fun _key() = key @JsonAnyGetter @ExcludeMissing @@ -79,54 +111,52 @@ private constructor( fun validate(): CreateApiKeyOutput = apply { if (!validated) { - id() - created() - name() - previewName() - userId() - orgId() - key() - validated = true + id() + created() + name() + previewName() + userId() + orgId() + key() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateApiKeyOutput && - this.id == other.id && - this.created == other.created && - this.name == other.name && - this.previewName == other.previewName && - this.userId == other.userId && - this.orgId == other.orgId && - this.key == other.key && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is CreateApiKeyOutput && + this.id == other.id && + this.created == other.created && + this.name == other.name && + this.previewName == other.previewName && + this.userId == other.userId && + this.orgId == other.orgId && + this.key == other.key && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - created, - name, - previewName, - userId, - orgId, - key, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + created, + name, + previewName, + userId, + orgId, + key, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "CreateApiKeyOutput{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, key=$key, additionalProperties=$additionalProperties}" + override fun toString() = "CreateApiKeyOutput{id=$id, created=$created, name=$name, previewName=$previewName, userId=$userId, orgId=$orgId, key=$key, additionalProperties=$additionalProperties}" companion object { @@ -159,7 +189,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the api key */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** Date of api key creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -167,7 +201,9 @@ private constructor( /** Date of api key creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** Name of the api key */ fun name(name: String) = name(JsonField.of(name)) @@ -175,13 +211,17 @@ private constructor( /** Name of the api key */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } fun previewName(previewName: String) = previewName(JsonField.of(previewName)) @JsonProperty("preview_name") @ExcludeMissing - fun previewName(previewName: JsonField) = apply { this.previewName = previewName } + fun previewName(previewName: JsonField) = apply { + this.previewName = previewName + } /** Unique identifier for the user */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -189,7 +229,9 @@ private constructor( /** Unique identifier for the user */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -197,7 +239,9 @@ private constructor( /** Unique identifier for the organization */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = apply { + this.orgId = orgId + } /** The raw API key. It will only be exposed this one time */ fun key(key: String) = key(JsonField.of(key)) @@ -205,7 +249,9 @@ private constructor( /** The raw API key. It will only be exposed this one time */ @JsonProperty("key") @ExcludeMissing - fun key(key: JsonField) = apply { this.key = key } + fun key(key: JsonField) = apply { + this.key = key + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -221,16 +267,15 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): CreateApiKeyOutput = - CreateApiKeyOutput( - id, - created, - name, - previewName, - userId, - orgId, - key, - additionalProperties.toUnmodifiable(), - ) + fun build(): CreateApiKeyOutput = CreateApiKeyOutput( + id, + created, + name, + previewName, + userId, + orgId, + key, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateDataset.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateDataset.kt deleted file mode 100755 index 18b9cabd..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateDataset.kt +++ /dev/null @@ -1,157 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = CreateDataset.Builder::class) -@NoAutoDetect -class CreateDataset -private constructor( - private val projectId: JsonField, - private val name: JsonField, - private val description: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the project that the dataset belongs under */ - fun projectId(): String? = projectId.getNullable("project_id") - - /** Name of the dataset. Within a project, dataset names are unique */ - fun name(): String = name.getRequired("name") - - /** Textual description of the dataset */ - fun description(): String? = description.getNullable("description") - - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the dataset */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreateDataset = apply { - if (!validated) { - projectId() - name() - description() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateDataset && - this.projectId == other.projectId && - this.name == other.name && - this.description == other.description && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectId, - name, - description, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateDataset{projectId=$projectId, name=$name, description=$description, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var projectId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createDataset: CreateDataset) = apply { - this.projectId = createDataset.projectId - this.name = createDataset.name - this.description = createDataset.description - additionalProperties(createDataset.additionalProperties) - } - - /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the dataset */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the dataset */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreateDataset = - CreateDataset( - projectId, - name, - description, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateExperiment.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateExperiment.kt deleted file mode 100755 index ef08f9c9..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateExperiment.kt +++ /dev/null @@ -1,422 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = CreateExperiment.Builder::class) -@NoAutoDetect -class CreateExperiment -private constructor( - private val projectId: JsonField, - private val name: JsonField, - private val description: JsonField, - private val repoInfo: JsonField, - private val baseExpId: JsonField, - private val datasetId: JsonField, - private val datasetVersion: JsonField, - private val public_: JsonField, - private val metadata: JsonField, - private val ensureNew: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the project that the experiment belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** Name of the experiment. Within a project, experiment names are unique */ - fun name(): String? = name.getNullable("name") - - /** Textual description of the experiment */ - fun description(): String? = description.getNullable("description") - - /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(): RepoInfo? = repoInfo.getNullable("repo_info") - - /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(): String? = baseExpId.getNullable("base_exp_id") - - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(): String? = datasetId.getNullable("dataset_id") - - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ - fun datasetVersion(): String? = datasetVersion.getNullable("dataset_version") - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization - */ - fun public_(): Boolean? = public_.getNullable("public") - - /** User-controlled metadata about the experiment */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** - * 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(): Boolean? = ensureNew.getNullable("ensure_new") - - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the experiment */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo() = repoInfo - - /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId() = baseExpId - - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId - - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ - @JsonProperty("dataset_version") @ExcludeMissing fun _datasetVersion() = datasetVersion - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization - */ - @JsonProperty("public") @ExcludeMissing fun _public_() = public_ - - /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** - * 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() = ensureNew - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreateExperiment = apply { - if (!validated) { - projectId() - name() - description() - repoInfo()?.validate() - baseExpId() - datasetId() - datasetVersion() - public_() - metadata()?.validate() - ensureNew() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateExperiment && - this.projectId == other.projectId && - this.name == other.name && - this.description == other.description && - this.repoInfo == other.repoInfo && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.public_ == other.public_ && - this.metadata == other.metadata && - this.ensureNew == other.ensureNew && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectId, - name, - description, - repoInfo, - baseExpId, - datasetId, - datasetVersion, - public_, - metadata, - ensureNew, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateExperiment{projectId=$projectId, name=$name, description=$description, repoInfo=$repoInfo, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, metadata=$metadata, ensureNew=$ensureNew, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var projectId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var repoInfo: JsonField = JsonMissing.of() - private var baseExpId: JsonField = JsonMissing.of() - private var datasetId: JsonField = JsonMissing.of() - private var datasetVersion: JsonField = JsonMissing.of() - private var public_: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var ensureNew: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createExperiment: CreateExperiment) = apply { - this.projectId = createExperiment.projectId - this.name = createExperiment.name - this.description = createExperiment.description - this.repoInfo = createExperiment.repoInfo - this.baseExpId = createExperiment.baseExpId - this.datasetId = createExperiment.datasetId - this.datasetVersion = createExperiment.datasetVersion - this.public_ = createExperiment.public_ - this.metadata = createExperiment.metadata - this.ensureNew = createExperiment.ensureNew - additionalProperties(createExperiment.additionalProperties) - } - - /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the experiment */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the experiment */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = repoInfo(JsonField.of(repoInfo)) - - /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - @ExcludeMissing - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } - - /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String) = baseExpId(JsonField.of(baseExpId)) - - /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - @ExcludeMissing - fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } - - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset - */ - fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) - - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset - */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ - fun datasetVersion(datasetVersion: String) = datasetVersion(JsonField.of(datasetVersion)) - - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ - @JsonProperty("dataset_version") - @ExcludeMissing - fun datasetVersion(datasetVersion: JsonField) = apply { - this.datasetVersion = datasetVersion - } - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ - fun public_(public_: Boolean) = public_(JsonField.of(public_)) - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ - @JsonProperty("public") - @ExcludeMissing - fun public_(public_: JsonField) = apply { this.public_ = public_ } - - /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** - * 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.of(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. - */ - @JsonProperty("ensure_new") - @ExcludeMissing - fun ensureNew(ensureNew: JsonField) = apply { this.ensureNew = ensureNew } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreateExperiment = - CreateExperiment( - projectId, - name, - description, - repoInfo, - baseExpId, - datasetId, - datasetVersion, - public_, - metadata, - ensureNew, - additionalProperties.toUnmodifiable(), - ) - } - - /** User-controlled metadata about the experiment */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateFunction.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateFunction.kt deleted file mode 100755 index fa317d78..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateFunction.kt +++ /dev/null @@ -1,1619 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(builder = CreateFunction.Builder::class) -@NoAutoDetect -class CreateFunction -private constructor( - private val projectId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val functionData: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** Name of the prompt */ - fun name(): String = name.getRequired("name") - - /** Unique identifier for the prompt */ - fun slug(): String = slug.getRequired("slug") - - /** Textual description of the prompt */ - fun description(): String? = description.getNullable("description") - - /** The prompt, model, and its parameters */ - fun promptData(): PromptData? = promptData.getNullable("prompt_data") - - /** A list of tags for the prompt */ - fun tags(): List? = tags.getNullable("tags") - - fun functionData(): FunctionData = functionData.getRequired("function_data") - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData - - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - @JsonProperty("function_data") @ExcludeMissing fun _functionData() = functionData - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreateFunction = apply { - if (!validated) { - projectId() - name() - slug() - description() - promptData()?.validate() - tags() - functionData() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateFunction && - this.projectId == other.projectId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.functionData == other.functionData && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectId, - name, - slug, - description, - promptData, - tags, - functionData, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateFunction{projectId=$projectId, name=$name, slug=$slug, description=$description, promptData=$promptData, tags=$tags, functionData=$functionData, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var projectId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var functionData: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createFunction: CreateFunction) = apply { - this.projectId = createFunction.projectId - this.name = createFunction.name - this.slug = createFunction.slug - this.description = createFunction.description - this.promptData = createFunction.promptData - this.tags = createFunction.tags - this.functionData = createFunction.functionData - additionalProperties(createFunction.additionalProperties) - } - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Unique identifier for the prompt */ - fun slug(slug: String) = slug(JsonField.of(slug)) - - /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } - - /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - - @JsonProperty("function_data") - @ExcludeMissing - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreateFunction = - CreateFunction( - projectId, - name, - slug, - description, - promptData, - tags.map { it.toUnmodifiable() }, - functionData, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = FunctionData.Deserializer::class) - @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( - private val prompt: Prompt? = null, - private val code: Code? = null, - private val global: Global? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun prompt(): Prompt? = prompt - - fun code(): Code? = code - - fun global(): Global? = global - - fun isPrompt(): Boolean = prompt != null - - fun isCode(): Boolean = code != null - - fun isGlobal(): Boolean = global != null - - fun asPrompt(): Prompt = prompt.getOrThrow("prompt") - - fun asCode(): Code = code.getOrThrow("code") - - fun asGlobal(): Global = global.getOrThrow("global") - - fun _json(): JsonValue? = _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) - } - } - - fun validate(): FunctionData = apply { - if (!validated) { - if (prompt == null && code == null && global == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - prompt?.validate() - code?.validate() - global?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionData && - this.prompt == other.prompt && - this.code == other.code && - this.global == other.global - } - - override fun hashCode(): Int { - return Objects.hash( - prompt, - code, - global, - ) - } - - override fun toString(): String { - return when { - prompt != null -> "FunctionData{prompt=$prompt}" - code != null -> "FunctionData{code=$code}" - global != null -> "FunctionData{global=$global}" - _json != null -> "FunctionData{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionData") - } - } - - companion object { - - fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - - fun ofCode(code: Code) = FunctionData(code = code) - - fun ofGlobal(global: Global) = FunctionData(global = global) - } - - interface Visitor { - - fun visitPrompt(prompt: Prompt): T - - fun visitCode(code: Code): T - - fun visitGlobal(global: Global): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") - } - } - - 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) - } - } - - 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") - } - } - } - - @JsonDeserialize(builder = Prompt.Builder::class) - @NoAutoDetect - class Prompt - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Prompt = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(prompt: Prompt) = apply { - this.type = prompt.type - additionalProperties(prompt.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val PROMPT = Type(JsonField.of("prompt")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - PROMPT, - } - - enum class Value { - PROMPT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PROMPT -> Value.PROMPT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PROMPT -> Known.PROMPT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = Code.Builder::class) - @NoAutoDetect - class Code - private constructor( - private val type: JsonField, - private val data: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Code = apply { - if (!validated) { - type() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Code && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(code: Code) = apply { - this.type = code.type - this.data = code.data - additionalProperties(code.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Code = - Code( - type, - data, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") - - fun location(): Location = location.getRequired("location") - - fun bundleId(): String = bundleId.getRequired("bundle_id") - - @JsonProperty("runtime_context") - @ExcludeMissing - fun _runtimeContext() = runtimeContext - - @JsonProperty("location") @ExcludeMissing fun _location() = location - - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - runtimeContext().validate() - location().validate() - bundleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtimeContext, - location, - bundleId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var runtimeContext: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var bundleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(data: Data) = apply { - this.runtimeContext = data.runtimeContext - this.location = data.location - this.bundleId = data.bundleId - additionalProperties(data.additionalProperties) - } - - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) - - @JsonProperty("runtime_context") - @ExcludeMissing - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } - - fun location(location: Location) = location(JsonField.of(location)) - - @JsonProperty("location") - @ExcludeMissing - fun location(location: JsonField) = apply { this.location = location } - - fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - - @JsonProperty("bundle_id") - @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - runtimeContext, - location, - bundleId, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Location.Builder::class) - @NoAutoDetect - class Location - private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun evalName(): String = evalName.getRequired("eval_name") - - fun position(): Position = position.getRequired("position") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName - - @JsonProperty("position") @ExcludeMissing fun _position() = position - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Location = apply { - if (!validated) { - type() - evalName() - position() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var evalName: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(location: Location) = apply { - this.type = location.type - this.evalName = location.evalName - this.position = location.position - additionalProperties(location.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun evalName(evalName: String) = evalName(JsonField.of(evalName)) - - @JsonProperty("eval_name") - @ExcludeMissing - fun evalName(evalName: JsonField) = apply { - this.evalName = evalName - } - - fun position(position: Position) = position(JsonField.of(position)) - - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { - this.position = position - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Location = - Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Position.Deserializer::class) - @JsonSerialize(using = Position.Serializer::class) - class Position - private constructor( - private val task: Task? = null, - private val score: Score? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun task(): Task? = task - - fun score(): Score? = score - - fun isTask(): Boolean = task != null - - fun isScore(): Boolean = score != null - - fun asTask(): Task = task.getOrThrow("task") - - fun asScore(): Score = score.getOrThrow("score") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - task != null -> visitor.visitTask(task) - score != null -> visitor.visitScore(score) - else -> visitor.unknown(_json) - } - } - - fun validate(): Position = apply { - if (!validated) { - if (task == null && score == null) { - throw BraintrustInvalidDataException("Unknown Position: $_json") - } - score?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Position && - this.task == other.task && - this.score == other.score - } - - override fun hashCode(): Int { - return Objects.hash(task, score) - } - - override fun toString(): String { - return when { - task != null -> "Position{task=$task}" - score != null -> "Position{score=$score}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") - } - } - - companion object { - - fun ofTask(task: Task) = Position(task = task) - - fun ofScore(score: Score) = Position(score = score) - } - - interface Visitor { - - fun visitTask(task: Task): T - - fun visitScore(score: Score): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") - } - } - - class Deserializer : BaseDeserializer(Position::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Position(task = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(score = it, _json = json) - } - - return Position(_json = json) - } - } - - class Serializer : BaseSerializer(Position::class) { - - override fun serialize( - value: Position, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.task != null -> generator.writeObject(value.task) - value.score != null -> generator.writeObject(value.score) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } - } - } - - class Task - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Task && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val TASK = Task(JsonField.of("task")) - - fun of(value: String) = Task(JsonField.of(value)) - } - - enum class Known { - TASK, - } - - enum class Value { - TASK, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException("Unknown Task: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Score.Builder::class) - @NoAutoDetect - class Score - private constructor( - private val score: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun score(): Double = score.getRequired("score") - - @JsonProperty("score") @ExcludeMissing fun _score() = score - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Score = apply { - if (!validated) { - score() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Score && - this.score == other.score && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(score, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Score{score=$score, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var score: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(score: Score) = apply { - this.score = score.score - additionalProperties(score.additionalProperties) - } - - fun score(score: Double) = score(JsonField.of(score)) - - @JsonProperty("score") - @ExcludeMissing - fun score(score: JsonField) = apply { this.score = score } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Score = - Score(score, additionalProperties.toUnmodifiable()) - } - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val EXPERIMENT = Type(JsonField.of("experiment")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - EXPERIMENT, - } - - enum class Value { - EXPERIMENT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = RuntimeContext.Builder::class) - @NoAutoDetect - class RuntimeContext - private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun runtime(): Runtime = runtime.getRequired("runtime") - - fun version(): String = version.getRequired("version") - - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): RuntimeContext = apply { - if (!validated) { - runtime() - version() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var runtime: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(runtimeContext: RuntimeContext) = apply { - this.runtime = runtimeContext.runtime - this.version = runtimeContext.version - additionalProperties(runtimeContext.additionalProperties) - } - - fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - - @JsonProperty("runtime") - @ExcludeMissing - fun runtime(runtime: JsonField) = apply { this.runtime = runtime } - - fun version(version: String) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): RuntimeContext = - RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) - } - - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Runtime && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val NODE = Runtime(JsonField.of("node")) - - fun of(value: String) = Runtime(JsonField.of(value)) - } - - enum class Known { - NODE, - } - - enum class Value { - NODE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NODE -> Value.NODE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NODE -> Known.NODE - else -> - throw BraintrustInvalidDataException("Unknown Runtime: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val CODE = Type(JsonField.of("code")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - CODE, - } - - enum class Value { - CODE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CODE -> Value.CODE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CODE -> Known.CODE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = Global.Builder::class) - @NoAutoDetect - class Global - private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun name(): String = name.getRequired("name") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Global = apply { - if (!validated) { - type() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(global: Global) = apply { - this.type = global.type - this.name = global.name - additionalProperties(global.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Global = - Global( - type, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val GLOBAL = Type(JsonField.of("global")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - GLOBAL, - } - - enum class Value { - GLOBAL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateGroup.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateGroup.kt deleted file mode 100755 index 74c98453..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateGroup.kt +++ /dev/null @@ -1,239 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = CreateGroup.Builder::class) -@NoAutoDetect -class CreateGroup -private constructor( - private val name: JsonField, - private val description: JsonField, - private val memberUsers: JsonField>, - private val memberGroups: JsonField>, - private val orgName: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the group */ - fun name(): String = name.getRequired("name") - - /** Textual description of the group */ - fun description(): String? = description.getNullable("description") - - /** Ids of users which belong to this group */ - fun memberUsers(): List? = memberUsers.getNullable("member_users") - - /** - * Ids of the groups this group inherits from - * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users - */ - fun memberGroups(): List? = memberGroups.getNullable("member_groups") - - /** - * For nearly all users, this parameter should 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(): String? = orgName.getNullable("org_name") - - /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the group */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Ids of users which belong to this group */ - @JsonProperty("member_users") @ExcludeMissing fun _memberUsers() = memberUsers - - /** - * Ids of the groups this group inherits from - * - * An inheriting group has all the users contained in its member groups, as well as all of their - * inherited users - */ - @JsonProperty("member_groups") @ExcludeMissing fun _memberGroups() = memberGroups - - /** - * For nearly all users, this parameter should 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() = orgName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreateGroup = apply { - if (!validated) { - name() - description() - memberUsers() - memberGroups() - orgName() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateGroup && - this.name == other.name && - this.description == other.description && - this.memberUsers == other.memberUsers && - this.memberGroups == other.memberGroups && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - memberUsers, - memberGroups, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateGroup{name=$name, description=$description, memberUsers=$memberUsers, memberGroups=$memberGroups, orgName=$orgName, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var memberUsers: JsonField> = JsonMissing.of() - private var memberGroups: JsonField> = JsonMissing.of() - private var orgName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createGroup: CreateGroup) = apply { - this.name = createGroup.name - this.description = createGroup.description - this.memberUsers = createGroup.memberUsers - this.memberGroups = createGroup.memberGroups - this.orgName = createGroup.orgName - additionalProperties(createGroup.additionalProperties) - } - - /** Name of the group */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the group */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the group */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the group */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Ids of users which belong to this group */ - fun memberUsers(memberUsers: List) = memberUsers(JsonField.of(memberUsers)) - - /** Ids of users which belong to this group */ - @JsonProperty("member_users") - @ExcludeMissing - fun memberUsers(memberUsers: JsonField>) = apply { - this.memberUsers = memberUsers - } - - /** - * Ids of the groups this group inherits from - * - * An inheriting group has all the users contained in its member groups, as well as all of - * their inherited users - */ - fun memberGroups(memberGroups: List) = memberGroups(JsonField.of(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 - */ - @JsonProperty("member_groups") - @ExcludeMissing - fun memberGroups(memberGroups: JsonField>) = apply { - this.memberGroups = memberGroups - } - - /** - * For nearly all users, this parameter should 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.of(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. - */ - @JsonProperty("org_name") - @ExcludeMissing - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreateGroup = - CreateGroup( - name, - description, - memberUsers.map { it.toUnmodifiable() }, - memberGroups.map { it.toUnmodifiable() }, - orgName, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProject.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProject.kt deleted file mode 100755 index aa405836..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProject.kt +++ /dev/null @@ -1,152 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = CreateProject.Builder::class) -@NoAutoDetect -class CreateProject -private constructor( - private val name: JsonField, - private val orgName: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** 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. - */ - fun orgName(): String? = orgName.getNullable("org_name") - - /** Name of the project */ - @JsonProperty("name") @ExcludeMissing fun _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. - */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName() = orgName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreateProject = apply { - if (!validated) { - name() - orgName() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateProject && - this.name == other.name && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateProject{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var orgName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createProject: CreateProject) = apply { - this.name = createProject.name - this.orgName = createProject.orgName - additionalProperties(createProject.additionalProperties) - } - - /** Name of the project */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the project */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** - * For nearly all users, this parameter should 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.of(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. - */ - @JsonProperty("org_name") - @ExcludeMissing - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreateProject = - CreateProject( - name, - orgName, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectScore.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectScore.kt deleted file mode 100755 index a2eaeaa8..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectScore.kt +++ /dev/null @@ -1,599 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(builder = CreateProjectScore.Builder::class) -@NoAutoDetect -class CreateProjectScore -private constructor( - private val projectId: JsonField, - private val name: JsonField, - private val description: JsonField, - private val scoreType: JsonField, - private val categories: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the project that the project score belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** Name of the project score */ - fun name(): String = name.getRequired("name") - - /** Textual description of the project score */ - fun description(): String? = description.getNullable("description") - - /** The type of the configured score */ - fun scoreType(): ScoreType? = scoreType.getNullable("score_type") - - fun categories(): Categories? = categories.getNullable("categories") - - /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the project score */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The type of the configured score */ - @JsonProperty("score_type") @ExcludeMissing fun _scoreType() = scoreType - - @JsonProperty("categories") @ExcludeMissing fun _categories() = categories - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreateProjectScore = apply { - if (!validated) { - projectId() - name() - description() - scoreType() - categories() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateProjectScore && - this.projectId == other.projectId && - this.name == other.name && - this.description == other.description && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectId, - name, - description, - scoreType, - categories, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateProjectScore{projectId=$projectId, name=$name, description=$description, scoreType=$scoreType, categories=$categories, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var projectId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var scoreType: JsonField = JsonMissing.of() - private var categories: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createProjectScore: CreateProjectScore) = apply { - this.projectId = createProjectScore.projectId - this.name = createProjectScore.name - this.description = createProjectScore.description - this.scoreType = createProjectScore.scoreType - this.categories = createProjectScore.categories - additionalProperties(createProjectScore.additionalProperties) - } - - /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Name of the project score */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the project score */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the project score */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the project score */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) - - /** The type of the configured score */ - @JsonProperty("score_type") - @ExcludeMissing - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } - - fun categories(categories: Categories) = categories(JsonField.of(categories)) - - @JsonProperty("categories") - @ExcludeMissing - fun categories(categories: JsonField) = apply { this.categories = categories } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreateProjectScore = - CreateProjectScore( - projectId, - name, - description, - scoreType, - categories, - additionalProperties.toUnmodifiable(), - ) - } - - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScoreType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val SLIDER = ScoreType(JsonField.of("slider")) - - val CATEGORICAL = ScoreType(JsonField.of("categorical")) - - val WEIGHTED = ScoreType(JsonField.of("weighted")) - - val MINIMUM = ScoreType(JsonField.of("minimum")) - - fun of(value: String) = ScoreType(JsonField.of(value)) - } - - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - } - - enum class Value { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(using = Categories.Deserializer::class) - @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( - private val projectScoreCategories: List? = null, - private val weighted: Weighted? = null, - private val strings: List? = null, - private val nullableVariant: NullableVariant? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(): List? = projectScoreCategories - /** For weighted-type project scores, the weights of each score */ - fun weighted(): Weighted? = weighted - /** For minimum-type project scores, the list of included scores */ - fun strings(): List? = strings - - fun nullableVariant(): NullableVariant? = nullableVariant - - fun isProjectScoreCategories(): Boolean = projectScoreCategories != null - - fun isWeighted(): Boolean = weighted != null - - fun isStrings(): Boolean = strings != null - - fun isNullableVariant(): Boolean = nullableVariant != null - - fun asProjectScoreCategories(): List = - projectScoreCategories.getOrThrow("projectScoreCategories") - - fun asWeighted(): Weighted = weighted.getOrThrow("weighted") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - projectScoreCategories != null -> - visitor.visitProjectScoreCategories(projectScoreCategories) - weighted != null -> visitor.visitWeighted(weighted) - strings != null -> visitor.visitStrings(strings) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } - } - - fun validate(): Categories = apply { - if (!validated) { - if ( - projectScoreCategories == null && - weighted == null && - strings == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - projectScoreCategories?.forEach { it.validate() } - weighted?.validate() - nullableVariant?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.weighted == other.weighted && - this.strings == other.strings && - this.nullableVariant == other.nullableVariant - } - - override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - weighted, - strings, - nullableVariant, - ) - } - - override fun toString(): String { - return when { - projectScoreCategories != null -> - "Categories{projectScoreCategories=$projectScoreCategories}" - weighted != null -> "Categories{weighted=$weighted}" - strings != null -> "Categories{strings=$strings}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" - _json != null -> "Categories{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Categories") - } - } - - companion object { - - fun ofProjectScoreCategories(projectScoreCategories: List) = - Categories(projectScoreCategories = projectScoreCategories) - - fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) - - fun ofStrings(strings: List) = Categories(strings = strings) - - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) - } - - interface Visitor { - - fun visitProjectScoreCategories(projectScoreCategories: List): T - - fun visitWeighted(weighted: Weighted): T - - fun visitStrings(strings: List): T - - fun visitNullableVariant(nullableVariant: NullableVariant): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") - } - } - - 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(projectScoreCategories = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) - } - } - - class Serializer : BaseSerializer(Categories::class) { - - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.projectScoreCategories != null -> - generator.writeObject(value.projectScoreCategories) - value.weighted != null -> generator.writeObject(value.weighted) - value.strings != null -> generator.writeObject(value.strings) - 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 */ - @JsonDeserialize(builder = Weighted.Builder::class) - @NoAutoDetect - class Weighted - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Weighted = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Weighted && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Weighted{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(weighted: Weighted) = apply { - additionalProperties(weighted.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) - } - } - - @JsonDeserialize(builder = NullableVariant.Builder::class) - @NoAutoDetect - class NullableVariant - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): NullableVariant = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NullableVariant && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectTag.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectTag.kt deleted file mode 100755 index 34d20cfb..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateProjectTag.kt +++ /dev/null @@ -1,178 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = CreateProjectTag.Builder::class) -@NoAutoDetect -class CreateProjectTag -private constructor( - private val projectId: JsonField, - private val name: JsonField, - private val description: JsonField, - private val color: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the project that the project tag belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** Name of the project tag */ - fun name(): String = name.getRequired("name") - - /** Textual description of the project tag */ - fun description(): String? = description.getNullable("description") - - /** Color of the tag for the UI */ - fun color(): String? = color.getNullable("color") - - /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the project tag */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color() = color - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreateProjectTag = apply { - if (!validated) { - projectId() - name() - description() - color() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateProjectTag && - this.projectId == other.projectId && - this.name == other.name && - this.description == other.description && - this.color == other.color && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectId, - name, - description, - color, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateProjectTag{projectId=$projectId, name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var projectId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var color: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createProjectTag: CreateProjectTag) = apply { - this.projectId = createProjectTag.projectId - this.name = createProjectTag.name - this.description = createProjectTag.description - this.color = createProjectTag.color - additionalProperties(createProjectTag.additionalProperties) - } - - /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Name of the project tag */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the project tag */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the project tag */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the project tag */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Color of the tag for the UI */ - fun color(color: String) = color(JsonField.of(color)) - - /** Color of the tag for the UI */ - @JsonProperty("color") - @ExcludeMissing - fun color(color: JsonField) = apply { this.color = color } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreateProjectTag = - CreateProjectTag( - projectId, - name, - description, - color, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreatePrompt.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreatePrompt.kt deleted file mode 100755 index 5c00626a..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreatePrompt.kt +++ /dev/null @@ -1,220 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = CreatePrompt.Builder::class) -@NoAutoDetect -class CreatePrompt -private constructor( - private val projectId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** Name of the prompt */ - fun name(): String = name.getRequired("name") - - /** Unique identifier for the prompt */ - fun slug(): String = slug.getRequired("slug") - - /** Textual description of the prompt */ - fun description(): String? = description.getNullable("description") - - /** The prompt, model, and its parameters */ - fun promptData(): PromptData? = promptData.getNullable("prompt_data") - - /** A list of tags for the prompt */ - fun tags(): List? = tags.getNullable("tags") - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData - - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreatePrompt = apply { - if (!validated) { - projectId() - name() - slug() - description() - promptData()?.validate() - tags() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreatePrompt && - this.projectId == other.projectId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectId, - name, - slug, - description, - promptData, - tags, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreatePrompt{projectId=$projectId, name=$name, slug=$slug, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var projectId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createPrompt: CreatePrompt) = apply { - this.projectId = createPrompt.projectId - this.name = createPrompt.name - this.slug = createPrompt.slug - this.description = createPrompt.description - this.promptData = createPrompt.promptData - this.tags = createPrompt.tags - additionalProperties(createPrompt.additionalProperties) - } - - /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Unique identifier for the prompt */ - fun slug(slug: String) = slug(JsonField.of(slug)) - - /** Unique identifier for the prompt */ - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } - - /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreatePrompt = - CreatePrompt( - projectId, - name, - slug, - description, - promptData, - tags.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateRole.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateRole.kt deleted file mode 100755 index a431297e..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateRole.kt +++ /dev/null @@ -1,596 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = CreateRole.Builder::class) -@NoAutoDetect -class CreateRole -private constructor( - private val name: JsonField, - private val description: JsonField, - private val memberPermissions: JsonField>, - private val memberRoles: JsonField>, - private val orgName: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the role */ - fun name(): String = name.getRequired("name") - - /** Textual description of the role */ - fun description(): String? = description.getNullable("description") - - /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): List? = - memberPermissions.getNullable("member_permissions") - - /** - * Ids of the roles this role inherits from - * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions - */ - fun memberRoles(): List? = memberRoles.getNullable("member_roles") - - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. - */ - fun orgName(): String? = orgName.getNullable("org_name") - - /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the role */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** (permission, restrict_object_type) tuples which belong to this role */ - @JsonProperty("member_permissions") @ExcludeMissing fun _memberPermissions() = memberPermissions - - /** - * Ids of the roles this role inherits from - * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions - */ - @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles() = memberRoles - - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that your - * API key belongs to multiple organizations, you may specify the name of the organization the - * role belongs in. - */ - @JsonProperty("org_name") @ExcludeMissing fun _orgName() = orgName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreateRole = apply { - if (!validated) { - name() - description() - memberPermissions()?.forEach { it.validate() } - memberRoles() - orgName() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateRole && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateRole{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var memberPermissions: JsonField> = JsonMissing.of() - private var memberRoles: JsonField> = JsonMissing.of() - private var orgName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createRole: CreateRole) = apply { - this.name = createRole.name - this.description = createRole.description - this.memberPermissions = createRole.memberPermissions - this.memberRoles = createRole.memberRoles - this.orgName = createRole.orgName - additionalProperties(createRole.additionalProperties) - } - - /** Name of the role */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the role */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the role */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the role */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List) = - memberPermissions(JsonField.of(memberPermissions)) - - /** (permission, restrict_object_type) tuples which belong to this role */ - @JsonProperty("member_permissions") - @ExcludeMissing - fun memberPermissions(memberPermissions: JsonField>) = apply { - this.memberPermissions = memberPermissions - } - - /** - * Ids of the roles this role inherits from - * - * An inheriting role has all the permissions contained in its member roles, as well as all - * of their inherited permissions - */ - fun memberRoles(memberRoles: List) = memberRoles(JsonField.of(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 - */ - @JsonProperty("member_roles") - @ExcludeMissing - fun memberRoles(memberRoles: JsonField>) = apply { - this.memberRoles = memberRoles - } - - /** - * For nearly all users, this parameter should be unnecessary. But in the rare case that - * your API key belongs to multiple organizations, you may specify the name of the - * organization the role belongs in. - */ - fun orgName(orgName: String) = orgName(JsonField.of(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. - */ - @JsonProperty("org_name") - @ExcludeMissing - fun orgName(orgName: JsonField) = apply { this.orgName = orgName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreateRole = - CreateRole( - name, - description, - memberPermissions.map { it.toUnmodifiable() }, - memberRoles.map { it.toUnmodifiable() }, - orgName, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = MemberPermission.Builder::class) - @NoAutoDetect - class MemberPermission - private constructor( - private val permission: JsonField, - private val restrictObjectType: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - fun permission(): Permission? = permission.getNullable("permission") - - /** The object type that the ACL applies to */ - fun restrictObjectType(): RestrictObjectType? = - restrictObjectType.getNullable("restrict_object_type") - - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - @JsonProperty("permission") @ExcludeMissing fun _permission() = permission - - /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - @ExcludeMissing - fun _restrictObjectType() = restrictObjectType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): MemberPermission = apply { - if (!validated) { - permission() - restrictObjectType() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var permission: JsonField = JsonMissing.of() - private var restrictObjectType: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(memberPermission: MemberPermission) = apply { - this.permission = memberPermission.permission - this.restrictObjectType = memberPermission.restrictObjectType - additionalProperties(memberPermission.additionalProperties) - } - - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles - */ - fun permission(permission: 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 - */ - @JsonProperty("permission") - @ExcludeMissing - fun permission(permission: JsonField) = apply { - this.permission = permission - } - - /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType) = - restrictObjectType(JsonField.of(restrictObjectType)) - - /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - @ExcludeMissing - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): MemberPermission = - MemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) - } - - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Permission && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val CREATE = Permission(JsonField.of("create")) - - val READ = Permission(JsonField.of("read")) - - val UPDATE = Permission(JsonField.of("update")) - - val DELETE = Permission(JsonField.of("delete")) - - val CREATE_ACLS = Permission(JsonField.of("create_acls")) - - val READ_ACLS = Permission(JsonField.of("read_acls")) - - val UPDATE_ACLS = Permission(JsonField.of("update_acls")) - - val DELETE_ACLS = Permission(JsonField.of("delete_acls")) - - fun of(value: String) = Permission(JsonField.of(value)) - } - - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - enum class Value { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RestrictObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val ORGANIZATION = RestrictObjectType(JsonField.of("organization")) - - val PROJECT = RestrictObjectType(JsonField.of("project")) - - val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) - - val DATASET = RestrictObjectType(JsonField.of("dataset")) - - val PROMPT = RestrictObjectType(JsonField.of("prompt")) - - val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) - - val GROUP = RestrictObjectType(JsonField.of("group")) - - val ROLE = RestrictObjectType(JsonField.of("role")) - - val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) - - val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) - - val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) - - fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateView.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateView.kt deleted file mode 100755 index 2f31a763..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CreateView.kt +++ /dev/null @@ -1,470 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects - -@JsonDeserialize(builder = CreateView.Builder::class) -@NoAutoDetect -class CreateView -private constructor( - private val objectType: JsonField, - private val objectId: JsonField, - private val viewType: JsonField, - private val name: JsonField, - private val viewData: JsonField, - private val options: JsonField, - private val userId: JsonField, - private val deletedAt: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The object type that the ACL applies to */ - fun objectType(): ObjectType? = objectType.getNullable("object_type") - - /** The id of the object the view applies to */ - fun objectId(): String = objectId.getRequired("object_id") - - /** Type of table that the view corresponds to. */ - fun viewType(): ViewType? = viewType.getNullable("view_type") - - /** Name of the view */ - fun name(): String = name.getRequired("name") - - /** The view definition */ - fun viewData(): ViewData? = viewData.getNullable("view_data") - - /** Options for the view in the app */ - fun options(): ViewOptions? = options.getNullable("options") - - /** Identifies the user who created the view */ - fun userId(): String? = userId.getNullable("user_id") - - /** Date of role deletion, or null if the role is still active */ - fun deletedAt(): OffsetDateTime? = deletedAt.getNullable("deleted_at") - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType - - /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId - - /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType() = viewType - - /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData() = viewData - - /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options() = options - - /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId - - /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CreateView = apply { - if (!validated) { - objectType() - objectId() - viewType() - name() - viewData()?.validate() - options()?.validate() - userId() - deletedAt() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CreateView && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.viewType == other.viewType && - this.name == other.name && - this.viewData == other.viewData && - this.options == other.options && - this.userId == other.userId && - this.deletedAt == other.deletedAt && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - viewType, - name, - viewData, - options, - userId, - deletedAt, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CreateView{objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, viewData=$viewData, options=$options, userId=$userId, deletedAt=$deletedAt, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var viewType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var viewData: JsonField = JsonMissing.of() - private var options: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var deletedAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(createView: CreateView) = apply { - this.objectType = createView.objectType - this.objectId = createView.objectId - this.viewType = createView.viewType - this.name = createView.name - this.viewData = createView.viewData - this.options = createView.options - this.userId = createView.userId - this.deletedAt = createView.deletedAt - additionalProperties(createView.additionalProperties) - } - - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } - - /** The id of the object the view applies to */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** The id of the object the view applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = viewType(JsonField.of(viewType)) - - /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - @ExcludeMissing - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } - - /** Name of the view */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the view */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The view definition */ - fun viewData(viewData: ViewData) = viewData(JsonField.of(viewData)) - - /** The view definition */ - @JsonProperty("view_data") - @ExcludeMissing - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } - - /** Options for the view in the app */ - fun options(options: ViewOptions) = options(JsonField.of(options)) - - /** Options for the view in the app */ - @JsonProperty("options") - @ExcludeMissing - fun options(options: JsonField) = apply { this.options = options } - - /** Identifies the user who created the view */ - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** Identifies the user who created the view */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } - - /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) - - /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") - @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CreateView = - CreateView( - objectType, - objectId, - viewType, - name, - viewData, - options, - userId, - deletedAt, - additionalProperties.toUnmodifiable(), - ) - } - - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val ORGANIZATION = ObjectType(JsonField.of("organization")) - - val PROJECT = ObjectType(JsonField.of("project")) - - val EXPERIMENT = ObjectType(JsonField.of("experiment")) - - val DATASET = ObjectType(JsonField.of("dataset")) - - val PROMPT = ObjectType(JsonField.of("prompt")) - - val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) - - val GROUP = ObjectType(JsonField.of("group")) - - val ROLE = ObjectType(JsonField.of("role")) - - val ORG_MEMBER = ObjectType(JsonField.of("org_member")) - - val PROJECT_LOG = ObjectType(JsonField.of("project_log")) - - val ORG_PROJECT = ObjectType(JsonField.of("org_project")) - - fun of(value: String) = ObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val PROJECTS = ViewType(JsonField.of("projects")) - - val LOGS = ViewType(JsonField.of("logs")) - - val EXPERIMENTS = ViewType(JsonField.of("experiments")) - - val DATASETS = ViewType(JsonField.of("datasets")) - - val PROMPTS = ViewType(JsonField.of("prompts")) - - val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) - - val EXPERIMENT = ViewType(JsonField.of("experiment")) - - val DATASET = ViewType(JsonField.of("dataset")) - - fun of(value: String) = ViewType(JsonField.of(value)) - } - - enum class Known { - PROJECTS, - LOGS, - EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, - EXPERIMENT, - DATASET, - } - - enum class Value { - PROJECTS, - LOGS, - EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, - EXPERIMENT, - DATASET, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequest.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequest.kt deleted file mode 100755 index bed70d5b..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequest.kt +++ /dev/null @@ -1,375 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = CrossObjectInsertRequest.Builder::class) -@NoAutoDetect -class CrossObjectInsertRequest -private constructor( - private val experiment: JsonField, - private val dataset: JsonField, - private val projectLogs: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A mapping from experiment id to a set of log events and feedback items to insert */ - fun experiment(): Experiment? = experiment.getNullable("experiment") - - /** A mapping from dataset id to a set of log events and feedback items to insert */ - fun dataset(): Dataset? = dataset.getNullable("dataset") - - /** A mapping from project id to a set of log events and feedback items to insert */ - fun projectLogs(): ProjectLogs? = projectLogs.getNullable("project_logs") - - /** A mapping from experiment id to a set of log events and feedback items to insert */ - @JsonProperty("experiment") @ExcludeMissing fun _experiment() = experiment - - /** A mapping from dataset id to a set of log events and feedback items to insert */ - @JsonProperty("dataset") @ExcludeMissing fun _dataset() = dataset - - /** A mapping from project id to a set of log events and feedback items to insert */ - @JsonProperty("project_logs") @ExcludeMissing fun _projectLogs() = projectLogs - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CrossObjectInsertRequest = apply { - if (!validated) { - experiment()?.validate() - dataset()?.validate() - projectLogs()?.validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CrossObjectInsertRequest && - this.experiment == other.experiment && - this.dataset == other.dataset && - this.projectLogs == other.projectLogs && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - experiment, - dataset, - projectLogs, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "CrossObjectInsertRequest{experiment=$experiment, dataset=$dataset, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var experiment: JsonField = JsonMissing.of() - private var dataset: JsonField = JsonMissing.of() - private var projectLogs: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(crossObjectInsertRequest: CrossObjectInsertRequest) = apply { - this.experiment = crossObjectInsertRequest.experiment - this.dataset = crossObjectInsertRequest.dataset - this.projectLogs = crossObjectInsertRequest.projectLogs - additionalProperties(crossObjectInsertRequest.additionalProperties) - } - - /** A mapping from experiment id to a set of log events and feedback items to insert */ - fun experiment(experiment: Experiment) = experiment(JsonField.of(experiment)) - - /** A mapping from experiment id to a set of log events and feedback items to insert */ - @JsonProperty("experiment") - @ExcludeMissing - fun experiment(experiment: JsonField) = apply { this.experiment = experiment } - - /** A mapping from dataset id to a set of log events and feedback items to insert */ - fun dataset(dataset: Dataset) = dataset(JsonField.of(dataset)) - - /** A mapping from dataset id to a set of log events and feedback items to insert */ - @JsonProperty("dataset") - @ExcludeMissing - fun dataset(dataset: JsonField) = apply { this.dataset = dataset } - - /** A mapping from project id to a set of log events and feedback items to insert */ - fun projectLogs(projectLogs: ProjectLogs) = projectLogs(JsonField.of(projectLogs)) - - /** A mapping from project id to a set of log events and feedback items to insert */ - @JsonProperty("project_logs") - @ExcludeMissing - fun projectLogs(projectLogs: JsonField) = apply { - this.projectLogs = projectLogs - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CrossObjectInsertRequest = - CrossObjectInsertRequest( - experiment, - dataset, - projectLogs, - additionalProperties.toUnmodifiable(), - ) - } - - /** A mapping from dataset id to a set of log events and feedback items to insert */ - @JsonDeserialize(builder = Dataset.Builder::class) - @NoAutoDetect - class Dataset - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Dataset = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Dataset && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Dataset{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(dataset: Dataset) = apply { - additionalProperties(dataset.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Dataset = Dataset(additionalProperties.toUnmodifiable()) - } - } - - /** A mapping from experiment id to a set of log events and feedback items to insert */ - @JsonDeserialize(builder = Experiment.Builder::class) - @NoAutoDetect - class Experiment - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Experiment = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Experiment && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Experiment{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(experiment: Experiment) = apply { - additionalProperties(experiment.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Experiment = Experiment(additionalProperties.toUnmodifiable()) - } - } - - /** A mapping from project id to a set of log events and feedback items to insert */ - @JsonDeserialize(builder = ProjectLogs.Builder::class) - @NoAutoDetect - class ProjectLogs - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectLogs = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogs && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "ProjectLogs{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(projectLogs: ProjectLogs) = apply { - additionalProperties(projectLogs.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectLogs = ProjectLogs(additionalProperties.toUnmodifiable()) - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt index b836efe2..ea5ad061 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponse.kt @@ -2,26 +2,45 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = CrossObjectInsertResponse.Builder::class) @NoAutoDetect -class CrossObjectInsertResponse -private constructor( - private val experiment: JsonField, - private val dataset: JsonField, - private val projectLogs: JsonField, - private val additionalProperties: Map, +class CrossObjectInsertResponse private constructor( + private val experiment: JsonField, + private val dataset: JsonField, + private val projectLogs: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -38,13 +57,19 @@ private constructor( fun projectLogs(): ProjectLogs? = projectLogs.getNullable("project_logs") /** A mapping from experiment id to row ids for inserted `events` */ - @JsonProperty("experiment") @ExcludeMissing fun _experiment() = experiment + @JsonProperty("experiment") + @ExcludeMissing + fun _experiment() = experiment /** A mapping from dataset id to row ids for inserted `events` */ - @JsonProperty("dataset") @ExcludeMissing fun _dataset() = dataset + @JsonProperty("dataset") + @ExcludeMissing + fun _dataset() = dataset /** A mapping from project id to row ids for inserted `events` */ - @JsonProperty("project_logs") @ExcludeMissing fun _projectLogs() = projectLogs + @JsonProperty("project_logs") + @ExcludeMissing + fun _projectLogs() = projectLogs @JsonAnyGetter @ExcludeMissing @@ -52,42 +77,40 @@ private constructor( fun validate(): CrossObjectInsertResponse = apply { if (!validated) { - experiment()?.validate() - dataset()?.validate() - projectLogs()?.validate() - validated = true + experiment()?.validate() + dataset()?.validate() + projectLogs()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CrossObjectInsertResponse && - this.experiment == other.experiment && - this.dataset == other.dataset && - this.projectLogs == other.projectLogs && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is CrossObjectInsertResponse && + this.experiment == other.experiment && + this.dataset == other.dataset && + this.projectLogs == other.projectLogs && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - experiment, - dataset, - projectLogs, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + experiment, + dataset, + projectLogs, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "CrossObjectInsertResponse{experiment=$experiment, dataset=$dataset, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" + override fun toString() = "CrossObjectInsertResponse{experiment=$experiment, dataset=$dataset, projectLogs=$projectLogs, additionalProperties=$additionalProperties}" companion object { @@ -114,7 +137,9 @@ private constructor( /** A mapping from experiment id to row ids for inserted `events` */ @JsonProperty("experiment") @ExcludeMissing - fun experiment(experiment: JsonField) = apply { this.experiment = experiment } + fun experiment(experiment: JsonField) = apply { + this.experiment = experiment + } /** A mapping from dataset id to row ids for inserted `events` */ fun dataset(dataset: Dataset) = dataset(JsonField.of(dataset)) @@ -122,7 +147,9 @@ private constructor( /** A mapping from dataset id to row ids for inserted `events` */ @JsonProperty("dataset") @ExcludeMissing - fun dataset(dataset: JsonField) = apply { this.dataset = dataset } + fun dataset(dataset: JsonField) = apply { + this.dataset = dataset + } /** A mapping from project id to row ids for inserted `events` */ fun projectLogs(projectLogs: ProjectLogs) = projectLogs(JsonField.of(projectLogs)) @@ -148,22 +175,18 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): CrossObjectInsertResponse = - CrossObjectInsertResponse( - experiment, - dataset, - projectLogs, - additionalProperties.toUnmodifiable(), - ) + fun build(): CrossObjectInsertResponse = CrossObjectInsertResponse( + experiment, + dataset, + projectLogs, + additionalProperties.toUnmodifiable(), + ) } /** A mapping from dataset id to row ids for inserted `events` */ @JsonDeserialize(builder = Dataset.Builder::class) @NoAutoDetect - class Dataset - private constructor( - private val additionalProperties: Map, - ) { + class Dataset private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -175,25 +198,26 @@ private constructor( fun validate(): Dataset = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Dataset && this.additionalProperties == other.additionalProperties + return other is Dataset && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Dataset{additionalProperties=$additionalProperties}" @@ -232,10 +256,7 @@ private constructor( /** A mapping from experiment id to row ids for inserted `events` */ @JsonDeserialize(builder = Experiment.Builder::class) @NoAutoDetect - class Experiment - private constructor( - private val additionalProperties: Map, - ) { + class Experiment private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -247,25 +268,26 @@ private constructor( fun validate(): Experiment = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Experiment && this.additionalProperties == other.additionalProperties + return other is Experiment && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Experiment{additionalProperties=$additionalProperties}" @@ -304,10 +326,7 @@ private constructor( /** A mapping from project id to row ids for inserted `events` */ @JsonDeserialize(builder = ProjectLogs.Builder::class) @NoAutoDetect - class ProjectLogs - private constructor( - private val additionalProperties: Map, - ) { + class ProjectLogs private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -319,25 +338,26 @@ private constructor( fun validate(): ProjectLogs = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectLogs && this.additionalProperties == other.additionalProperties + return other is ProjectLogs && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ProjectLogs{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt index c4bc653c..38e7f203 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DataSummary.kt @@ -2,26 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** Summary of a dataset's data */ @JsonDeserialize(builder = DataSummary.Builder::class) @NoAutoDetect -class DataSummary -private constructor( - private val totalRecords: JsonField, - private val additionalProperties: Map, -) { +class DataSummary private constructor(private val totalRecords: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -31,7 +46,9 @@ private constructor( fun totalRecords(): Long = totalRecords.getRequired("total_records") /** Total number of records in the dataset */ - @JsonProperty("total_records") @ExcludeMissing fun _totalRecords() = totalRecords + @JsonProperty("total_records") + @ExcludeMissing + fun _totalRecords() = totalRecords @JsonAnyGetter @ExcludeMissing @@ -39,32 +56,31 @@ private constructor( fun validate(): DataSummary = apply { if (!validated) { - totalRecords() - validated = true + totalRecords() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is DataSummary && - this.totalRecords == other.totalRecords && - this.additionalProperties == other.additionalProperties + return other is DataSummary && + this.totalRecords == other.totalRecords && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(totalRecords, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(totalRecords, additionalProperties) + } + return hashCode } - override fun toString() = - "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" + override fun toString() = "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" companion object { @@ -87,7 +103,9 @@ private constructor( /** Total number of records in the dataset */ @JsonProperty("total_records") @ExcludeMissing - fun totalRecords(totalRecords: JsonField) = apply { this.totalRecords = totalRecords } + fun totalRecords(totalRecords: JsonField) = apply { + this.totalRecords = totalRecords + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt index e4378352..eae2305b 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Dataset.kt @@ -2,32 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Dataset.Builder::class) @NoAutoDetect -class Dataset -private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val name: JsonField, - private val description: JsonField, - private val created: JsonField, - private val deletedAt: JsonField, - private val userId: JsonField, - private val metadata: JsonField, - private val additionalProperties: Map, +class Dataset private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val name: JsonField, + private val description: JsonField, + private val created: JsonField, + private val deletedAt: JsonField, + private val userId: JsonField, + private val metadata: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -59,28 +77,44 @@ private constructor( fun metadata(): Metadata? = metadata.getNullable("metadata") /** Unique identifier for the dataset */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId() = projectId /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Textual description of the dataset */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description() = description /** Date of dataset creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Date of dataset deletion, or null if the dataset is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt() = deletedAt /** Identifies the user who created the dataset */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata @JsonAnyGetter @ExcludeMissing @@ -88,57 +122,55 @@ private constructor( fun validate(): Dataset = apply { if (!validated) { - id() - projectId() - name() - description() - created() - deletedAt() - userId() - metadata()?.validate() - validated = true + id() + projectId() + name() + description() + created() + deletedAt() + userId() + metadata()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Dataset && - this.id == other.id && - this.projectId == other.projectId && - this.name == other.name && - this.description == other.description && - this.created == other.created && - this.deletedAt == other.deletedAt && - this.userId == other.userId && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Dataset && + this.id == other.id && + this.projectId == other.projectId && + this.name == other.name && + this.description == other.description && + this.created == other.created && + this.deletedAt == other.deletedAt && + this.userId == other.userId && + this.metadata == other.metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - projectId, - name, - description, - created, - deletedAt, - userId, - metadata, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + projectId, + name, + description, + created, + deletedAt, + userId, + metadata, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Dataset{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, deletedAt=$deletedAt, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = "Dataset{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, deletedAt=$deletedAt, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" companion object { @@ -173,7 +205,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the dataset */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -181,7 +217,9 @@ private constructor( /** Unique identifier for the project that the dataset belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } /** Name of the dataset. Within a project, dataset names are unique */ fun name(name: String) = name(JsonField.of(name)) @@ -189,7 +227,9 @@ private constructor( /** Name of the dataset. Within a project, dataset names are unique */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } /** Textual description of the dataset */ fun description(description: String) = description(JsonField.of(description)) @@ -197,7 +237,9 @@ private constructor( /** Textual description of the dataset */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } /** Date of dataset creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -205,7 +247,9 @@ private constructor( /** Date of dataset creation */ @JsonProperty("created") @ExcludeMissing - 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.of(deletedAt)) @@ -213,7 +257,9 @@ private constructor( /** Date of dataset deletion, or null if the dataset is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } /** Identifies the user who created the dataset */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -221,7 +267,9 @@ private constructor( /** Identifies the user who created the dataset */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } /** User-controlled metadata about the dataset */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) @@ -229,7 +277,9 @@ private constructor( /** User-controlled metadata about the dataset */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -245,27 +295,23 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Dataset = - Dataset( - id, - projectId, - name, - description, - created, - deletedAt, - userId, - metadata, - additionalProperties.toUnmodifiable(), - ) + fun build(): Dataset = Dataset( + id, + projectId, + name, + description, + created, + deletedAt, + userId, + metadata, + additionalProperties.toUnmodifiable(), + ) } /** User-controlled metadata about the dataset */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -277,25 +323,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt index a32aa582..fa35e702 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetCreateParams.kt @@ -2,25 +2,48 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class DatasetCreateParams constructor( + private val name: String, + private val description: String?, + private val projectId: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class DatasetCreateParams -constructor( - private val name: String, - private val description: String?, - private val projectId: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -30,12 +53,12 @@ constructor( fun projectId(): String? = projectId internal fun getBody(): DatasetCreateBody { - return DatasetCreateBody( - name, - description, - projectId, - additionalBodyProperties, - ) + return DatasetCreateBody( + name, + description, + projectId, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -44,24 +67,27 @@ constructor( @JsonDeserialize(builder = DatasetCreateBody.Builder::class) @NoAutoDetect - class DatasetCreateBody - internal constructor( - private val name: String?, - private val description: String?, - private val projectId: String?, - private val additionalProperties: Map, + class DatasetCreateBody internal constructor( + private val name: String?, + private val description: String?, + private val projectId: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Textual description of the dataset */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") + fun projectId(): String? = projectId @JsonAnyGetter @ExcludeMissing @@ -70,32 +96,30 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetCreateBody && - this.name == other.name && - this.description == other.description && - this.projectId == other.projectId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is DatasetCreateBody && + this.name == other.name && + this.description == other.description && + this.projectId == other.projectId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - projectId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + description, + projectId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "DatasetCreateBody{name=$name, description=$description, projectId=$projectId, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetCreateBody{name=$name, description=$description, projectId=$projectId, additionalProperties=$additionalProperties}" companion object { @@ -117,15 +141,22 @@ constructor( } /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Textual description of the dataset */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Unique identifier for the project that the dataset belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -141,13 +172,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetCreateBody = - DatasetCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - description, - projectId, - additionalProperties.toUnmodifiable(), - ) + fun build(): DatasetCreateBody = DatasetCreateBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + description, + projectId, + additionalProperties.toUnmodifiable(), + ) } } @@ -158,32 +190,31 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetCreateParams && - this.name == other.name && - this.description == other.description && - this.projectId == other.projectId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetCreateParams && + this.name == other.name && + this.description == other.description && + this.projectId == other.projectId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - description, - projectId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + description, + projectId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "DatasetCreateParams{name=$name, description=$description, projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "DatasetCreateParams{name=$name, description=$description, projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -212,13 +243,19 @@ constructor( } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Textual description of the dataset */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -258,7 +295,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -269,19 +308,19 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetCreateParams = - DatasetCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - description, - projectId, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetCreateParams = DatasetCreateParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + description, + projectId, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt index 55f0472d..aedaec3f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class DatasetDeleteParams -constructor( - private val datasetId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class DatasetDeleteParams constructor( + private val datasetId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun datasetId(): String = datasetId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetDeleteParams && - this.datasetId == other.datasetId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetDeleteParams && + this.datasetId == other.datasetId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "DatasetDeleteParams{datasetId=$datasetId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "DatasetDeleteParams{datasetId=$datasetId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = apply { + this.datasetId = datasetId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): DatasetDeleteParams = - DatasetDeleteParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): DatasetDeleteParams = DatasetDeleteParams( + checkNotNull(datasetId) { + "`datasetId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt index 621992d3..6a25bbfc 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetEvent.kt @@ -2,35 +2,53 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = DatasetEvent.Builder::class) @NoAutoDetect -class DatasetEvent -private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val datasetId: JsonField, - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val spanId: JsonField, - private val rootSpanId: JsonField, - private val additionalProperties: Map, +class DatasetEvent private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val projectId: JsonField, + private val datasetId: JsonField, + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val spanId: JsonField, + private val rootSpanId: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -38,15 +56,16 @@ private constructor( private var hashCode: Int = 0 /** - * 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") @@ -59,21 +78,24 @@ private constructor( /** Unique identifier for the dataset */ fun datasetId(): String = datasetId.getRequired("dataset_id") - /** 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(): JsonValue = input /** - * 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) */ fun expected(): JsonValue = expected /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else 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.getNullable("metadata") @@ -81,9 +103,10 @@ private constructor( fun tags(): List? = tags.getNullable("tags") /** - * A unique identifier used to link different dataset events together as part of a full trace. - * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on - * tracing + * 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") @@ -91,57 +114,84 @@ private constructor( fun rootSpanId(): String = rootSpanId.getRequired("root_span_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 */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _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) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId() = _xactId /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId() = projectId /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId - - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input() = input + @JsonProperty("dataset_id") + @ExcludeMissing + fun _datasetId() = datasetId /** - * The output of your application, including post-processing (an arbitrary, JSON serializable + * The argument that uniquely define an input case (an arbitrary, JSON serializable * object) */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("input") + @ExcludeMissing + fun _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 + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected + + /** + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** - * A unique identifier used to link different dataset events together as part of a full trace. - * See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on - * tracing + * A unique identifier used to link different dataset events together as part of a + * full trace. See the + * [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details + * on tracing */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId() = spanId /** The `span_id` of the root of the trace this dataset event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId() = rootSpanId @JsonAnyGetter @ExcludeMissing @@ -149,66 +199,64 @@ private constructor( fun validate(): DatasetEvent = apply { if (!validated) { - id() - _xactId() - created() - projectId() - datasetId() - input() - expected() - metadata()?.validate() - tags() - spanId() - rootSpanId() - validated = true + id() + _xactId() + created() + projectId() + datasetId() + input() + expected() + metadata()?.validate() + tags() + spanId() + rootSpanId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetEvent && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.datasetId == other.datasetId && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.spanId == other.spanId && - this.rootSpanId == other.rootSpanId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is DatasetEvent && + this.id == other.id && + this._xactId == other._xactId && + this.created == other.created && + this.projectId == other.projectId && + this.datasetId == other.datasetId && + this.input == other.input && + this.expected == other.expected && + this.metadata == other.metadata && + this.tags == other.tags && + this.spanId == other.spanId && + this.rootSpanId == other.rootSpanId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - created, - projectId, - datasetId, - input, - expected, - metadata, - tags, - spanId, - rootSpanId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + _xactId, + created, + projectId, + datasetId, + input, + expected, + metadata, + tags, + spanId, + rootSpanId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetEvent{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" companion object { @@ -246,32 +294,40 @@ private constructor( } /** - * 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 */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + 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) */ @JsonProperty("_xact_id") @ExcludeMissing - 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)) @@ -279,7 +335,9 @@ private constructor( /** The timestamp the dataset event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** Unique identifier for the project that the dataset belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -287,7 +345,9 @@ private constructor( /** Unique identifier for the project that the dataset belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } /** Unique identifier for the dataset */ fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) @@ -295,14 +355,19 @@ private constructor( /** Unique identifier for the dataset */ @JsonProperty("dataset_id") @ExcludeMissing - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: JsonField) = apply { + this.datasetId = datasetId + } /** - * 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) */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { + this.input = input + } /** * The output of your application, including post-processing (an arbitrary, JSON @@ -310,27 +375,31 @@ private constructor( */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -338,23 +407,29 @@ private constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing + * 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 */ @JsonProperty("span_id") @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = apply { + this.spanId = spanId + } /** The `span_id` of the root of the trace this dataset event belongs to */ fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) @@ -362,7 +437,9 @@ private constructor( /** The `span_id` of the root of the trace this dataset event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = apply { + this.rootSpanId = rootSpanId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -378,36 +455,32 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetEvent = - DatasetEvent( - id, - _xactId, - created, - projectId, - datasetId, - input, - expected, - metadata, - tags.map { it.toUnmodifiable() }, - spanId, - rootSpanId, - additionalProperties.toUnmodifiable(), - ) + fun build(): DatasetEvent = DatasetEvent( + id, + _xactId, + created, + projectId, + datasetId, + input, + expected, + metadata, + tags.map { it.toUnmodifiable() }, + spanId, + rootSpanId, + additionalProperties.toUnmodifiable(), + ) } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else 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 */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -419,25 +492,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt index caaa6cb1..68732630 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFeedbackParams.kt @@ -2,24 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class DatasetFeedbackParams constructor( + private val datasetId: String, + private val feedback: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class DatasetFeedbackParams -constructor( - private val datasetId: String, - private val feedback: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @@ -27,7 +50,7 @@ constructor( fun feedback(): List = feedback internal fun getBody(): DatasetFeedbackBody { - return DatasetFeedbackBody(feedback, additionalBodyProperties) + return DatasetFeedbackBody(feedback, additionalBodyProperties) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -35,24 +58,21 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @JsonDeserialize(builder = DatasetFeedbackBody.Builder::class) @NoAutoDetect - class DatasetFeedbackBody - internal constructor( - private val feedback: List?, - private val additionalProperties: Map, - ) { + class DatasetFeedbackBody internal constructor(private val feedback: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of dataset feedback items */ - @JsonProperty("feedback") fun feedback(): List? = feedback + @JsonProperty("feedback") + fun feedback(): List? = feedback @JsonAnyGetter @ExcludeMissing @@ -61,24 +81,23 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is DatasetFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties + return other is DatasetFeedbackBody && + this.feedback == other.feedback && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(feedback, additionalProperties) + } + return hashCode } - override fun toString() = - "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" companion object { @@ -97,7 +116,9 @@ constructor( /** A list of dataset feedback items */ @JsonProperty("feedback") - fun feedback(feedback: List) = apply { this.feedback = feedback } + fun feedback(feedback: List) = apply { + this.feedback = feedback + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -113,12 +134,9 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetFeedbackBody = - DatasetFeedbackBody( - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() - ) + fun build(): DatasetFeedbackBody = DatasetFeedbackBody(checkNotNull(feedback) { + "`feedback` is required but was not set" + }.toUnmodifiable(), additionalProperties.toUnmodifiable()) } } @@ -129,30 +147,29 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFeedbackParams && - this.datasetId == other.datasetId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetFeedbackParams && + this.datasetId == other.datasetId && + this.feedback == other.feedback && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + feedback, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "DatasetFeedbackParams{datasetId=$datasetId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "DatasetFeedbackParams{datasetId=$datasetId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -179,7 +196,9 @@ constructor( } /** 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 { @@ -188,7 +207,9 @@ constructor( } /** A list of dataset feedback items */ - fun addFeedback(feedback: FeedbackDatasetItem) = apply { this.feedback.add(feedback) } + fun addFeedback(feedback: FeedbackDatasetItem) = apply { + this.feedback.add(feedback) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -228,7 +249,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -239,19 +262,20 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetFeedbackParams = - DatasetFeedbackParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetFeedbackParams = DatasetFeedbackParams( + checkNotNull(datasetId) { + "`datasetId` is required but was not set" + }, + checkNotNull(feedback) { + "`feedback` is required but was not set" + }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt index dbf7f486..b5d0d349 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchParams.kt @@ -2,20 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class DatasetFetchParams -constructor( - private val datasetId: String, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, +class DatasetFetchParams constructor( + private val datasetId: String, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + ) { fun datasetId(): String = datasetId @@ -29,22 +58,30 @@ constructor( fun version(): String? = version internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { params.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } - this.version?.let { params.put("version", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.maxRootSpanId?.let { + params.put("max_root_span_id", listOf(it.toString())) + } + this.maxXactId?.let { + params.put("max_xact_id", listOf(it.toString())) + } + this.version?.let { + params.put("version", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -52,34 +89,33 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFetchParams && - this.datasetId == other.datasetId && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is DatasetFetchParams && + this.datasetId == other.datasetId && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - datasetId, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + datasetId, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "DatasetFetchParams{datasetId=$datasetId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -110,60 +146,72 @@ constructor( } /** 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 + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the 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 maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String) = 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) = apply { this.version = version } + fun version(version: String) = apply { + this.version = version + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -203,17 +251,20 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): DatasetFetchParams = - DatasetFetchParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): DatasetFetchParams = DatasetFetchParams( + checkNotNull(datasetId) { + "`datasetId` is required but was not set" + }, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt index 51faeb06..80c05c4e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostParams.kt @@ -2,29 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class DatasetFetchPostParams constructor( + private val datasetId: String, + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class DatasetFetchPostParams -constructor( - private val datasetId: String, - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @@ -42,15 +65,15 @@ constructor( fun version(): String? = version internal fun getBody(): DatasetFetchPostBody { - return DatasetFetchPostBody( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalBodyProperties, - ) + return DatasetFetchPostBody( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -58,98 +81,106 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @JsonDeserialize(builder = DatasetFetchPostBody.Builder::class) @NoAutoDetect - class DatasetFetchPostBody - internal constructor( - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalProperties: Map, + class DatasetFetchPostBody internal constructor( + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * 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") fun cursor(): String? = cursor + @JsonProperty("cursor") + fun cursor(): String? = cursor /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ - @JsonProperty("filters") fun filters(): List? = filters + @JsonProperty("filters") + fun filters(): List? = filters /** * 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. */ - @JsonProperty("limit") fun limit(): Long? = limit + @JsonProperty("limit") + fun limit(): Long? = 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") fun maxRootSpanId(): String? = maxRootSpanId + @JsonProperty("max_root_span_id") + fun maxRootSpanId(): String? = 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") fun maxXactId(): String? = maxXactId + @JsonProperty("max_xact_id") + fun maxXactId(): String? = 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") fun version(): String? = version + @JsonProperty("version") + fun version(): String? = version @JsonAnyGetter @ExcludeMissing @@ -158,38 +189,36 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFetchPostBody && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is DatasetFetchPostBody && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -217,80 +246,96 @@ constructor( } /** - * 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") fun cursor(cursor: String) = apply { this.cursor = cursor } + @JsonProperty("cursor") + fun cursor(cursor: String) = apply { + this.cursor = cursor + } /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters - * are supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } + fun filters(filters: List) = apply { + this.filters = filters + } /** * 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. */ - @JsonProperty("limit") fun limit(limit: Long) = apply { this.limit = limit } + @JsonProperty("limit") + fun limit(limit: Long) = 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. */ @JsonProperty("max_root_span_id") - 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. */ @JsonProperty("max_xact_id") - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String) = 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. */ - @JsonProperty("version") fun version(version: String) = apply { this.version = version } + @JsonProperty("version") + fun version(version: String) = apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -306,16 +351,15 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetFetchPostBody = - DatasetFetchPostBody( - cursor, - filters?.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): DatasetFetchPostBody = DatasetFetchPostBody( + cursor, + filters?.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toUnmodifiable(), + ) } } @@ -326,40 +370,39 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFetchPostParams && - this.datasetId == other.datasetId && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetFetchPostParams && + this.datasetId == other.datasetId && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "DatasetFetchPostParams{datasetId=$datasetId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -396,24 +439,28 @@ constructor( } /** 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 { this.cursor = cursor } + fun cursor(cursor: String) = apply { + this.cursor = cursor + } /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ fun filters(filters: List) = apply { this.filters.clear() @@ -421,67 +468,79 @@ constructor( } /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ - fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } + fun addFilter(filter: PathLookupFilter) = apply { + this.filters.add(filter) + } /** * 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 + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the 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 maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String) = 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) = apply { this.version = version } + fun version(version: String) = apply { + this.version = version + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -521,7 +580,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -532,23 +593,23 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetFetchPostParams = - DatasetFetchPostParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - cursor, - if (filters.size == 0) null else filters.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetFetchPostParams = DatasetFetchPostParams( + checkNotNull(datasetId) { + "`datasetId` is required but was not set" + }, + cursor, + if(filters.size == 0) null else filters.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponse.kt deleted file mode 100755 index 5b590097..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponse.kt +++ /dev/null @@ -1,624 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects - -@JsonDeserialize(builder = DatasetFetchPostResponse.Builder::class) -@NoAutoDetect -class DatasetFetchPostResponse -private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of fetched events */ - fun events(): List = events.getRequired("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. - */ - fun cursor(): String? = cursor.getNullable("cursor") - - /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = 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. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): DatasetFetchPostResponse = apply { - if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFetchPostResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "DatasetFetchPostResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var events: JsonField> = JsonMissing.of() - private var cursor: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(datasetFetchPostResponse: DatasetFetchPostResponse) = apply { - this.events = datasetFetchPostResponse.events - this.cursor = datasetFetchPostResponse.cursor - additionalProperties(datasetFetchPostResponse.additionalProperties) - } - - /** A list of fetched events */ - fun events(events: List) = events(JsonField.of(events)) - - /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } - - /** - * Pagination cursor - * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. - */ - fun cursor(cursor: String) = cursor(JsonField.of(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. - */ - @JsonProperty("cursor") - @ExcludeMissing - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): DatasetFetchPostResponse = - DatasetFetchPostResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Event.Builder::class) - @NoAutoDetect - class Event - private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val datasetId: JsonField, - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val spanId: JsonField, - private val rootSpanId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - 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) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** The timestamp the dataset event was created */ - fun created(): OffsetDateTime = created.getRequired("created") - - /** Unique identifier for the project that the dataset belongs under */ - fun projectId(): String? = projectId.getNullable("project_id") - - /** Unique identifier for the dataset */ - fun datasetId(): String = datasetId.getRequired("dataset_id") - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - fun expected(): JsonValue = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** A list of tags to log */ - fun tags(): List? = tags.getNullable("tags") - - /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing - */ - fun spanId(): String = spanId.getRequired("span_id") - - /** The `span_id` of the root of the trace this dataset event belongs to */ - fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the dataset (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing - */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId - - /** The `span_id` of the root of the trace this dataset event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Event = apply { - if (!validated) { - id() - _xactId() - created() - projectId() - datasetId() - input() - expected() - metadata()?.validate() - tags() - spanId() - rootSpanId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.datasetId == other.datasetId && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.spanId == other.spanId && - this.rootSpanId == other.rootSpanId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - created, - projectId, - datasetId, - input, - expected, - metadata, - tags, - spanId, - rootSpanId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Event{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var datasetId: JsonField = JsonMissing.of() - private var input: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(event: Event) = apply { - this.id = event.id - this._xactId = event._xactId - this.created = event.created - this.projectId = event.projectId - this.datasetId = event.datasetId - this.input = event.input - this.expected = event.expected - this.metadata = event.metadata - this.tags = event.tags - this.spanId = event.spanId - this.rootSpanId = event.rootSpanId - additionalProperties(event.additionalProperties) - } - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** - * The 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) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** The timestamp the dataset event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Unique identifier for the dataset */ - fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) - - /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * A unique identifier 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 - */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } - - /** The `span_id` of the root of the trace this dataset event belongs to */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - - /** The `span_id` of the root of the trace this dataset event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Event = - Event( - id, - _xactId, - created, - projectId, - datasetId, - input, - expected, - metadata, - tags.map { it.toUnmodifiable() }, - spanId, - rootSpanId, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchResponse.kt deleted file mode 100755 index 2629b454..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetFetchResponse.kt +++ /dev/null @@ -1,624 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects - -@JsonDeserialize(builder = DatasetFetchResponse.Builder::class) -@NoAutoDetect -class DatasetFetchResponse -private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of fetched events */ - fun events(): List = events.getRequired("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. - */ - fun cursor(): String? = cursor.getNullable("cursor") - - /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = 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. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): DatasetFetchResponse = apply { - if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetFetchResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "DatasetFetchResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var events: JsonField> = JsonMissing.of() - private var cursor: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(datasetFetchResponse: DatasetFetchResponse) = apply { - this.events = datasetFetchResponse.events - this.cursor = datasetFetchResponse.cursor - additionalProperties(datasetFetchResponse.additionalProperties) - } - - /** A list of fetched events */ - fun events(events: List) = events(JsonField.of(events)) - - /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } - - /** - * Pagination cursor - * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. - */ - fun cursor(cursor: String) = cursor(JsonField.of(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. - */ - @JsonProperty("cursor") - @ExcludeMissing - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): DatasetFetchResponse = - DatasetFetchResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Event.Builder::class) - @NoAutoDetect - class Event - private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val datasetId: JsonField, - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val spanId: JsonField, - private val rootSpanId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - 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) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** The timestamp the dataset event was created */ - fun created(): OffsetDateTime = created.getRequired("created") - - /** Unique identifier for the project that the dataset belongs under */ - fun projectId(): String? = projectId.getNullable("project_id") - - /** Unique identifier for the dataset */ - fun datasetId(): String = datasetId.getRequired("dataset_id") - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - fun expected(): JsonValue = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** A list of tags to log */ - fun tags(): List? = tags.getNullable("tags") - - /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing - */ - fun spanId(): String = spanId.getRequired("span_id") - - /** The `span_id` of the root of the trace this dataset event belongs to */ - fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the dataset (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable object) - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * A unique identifier used to link different dataset events together as part of a full - * trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full - * details on tracing - */ - @JsonProperty("span_id") @ExcludeMissing fun _spanId() = spanId - - /** The `span_id` of the root of the trace this dataset event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Event = apply { - if (!validated) { - id() - _xactId() - created() - projectId() - datasetId() - input() - expected() - metadata()?.validate() - tags() - spanId() - rootSpanId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.datasetId == other.datasetId && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.spanId == other.spanId && - this.rootSpanId == other.rootSpanId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - created, - projectId, - datasetId, - input, - expected, - metadata, - tags, - spanId, - rootSpanId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Event{id=$id, _xactId=$_xactId, created=$created, projectId=$projectId, datasetId=$datasetId, input=$input, expected=$expected, metadata=$metadata, tags=$tags, spanId=$spanId, rootSpanId=$rootSpanId, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var datasetId: JsonField = JsonMissing.of() - private var input: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(event: Event) = apply { - this.id = event.id - this._xactId = event._xactId - this.created = event.created - this.projectId = event.projectId - this.datasetId = event.datasetId - this.input = event.input - this.expected = event.expected - this.metadata = event.metadata - this.tags = event.tags - this.spanId = event.spanId - this.rootSpanId = event.rootSpanId - additionalProperties(event.additionalProperties) - } - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** - * The 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) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** The timestamp the dataset event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the dataset event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** Unique identifier for the project that the dataset belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the dataset belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Unique identifier for the dataset */ - fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) - - /** Unique identifier for the dataset */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - - /** - * The argument that uniquely define an input case (an arbitrary, JSON serializable - * object) - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object) - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * A unique identifier 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 - */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } - - /** The `span_id` of the root of the trace this dataset event belongs to */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - - /** The `span_id` of the root of the trace this dataset event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Event = - Event( - id, - _xactId, - created, - projectId, - datasetId, - input, - expected, - metadata, - tags.map { it.toUnmodifiable() }, - spanId, - rootSpanId, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt index 13f32896..f8cddf8a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertParams.kt @@ -2,34 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class DatasetInsertParams constructor( + private val datasetId: String, + private val events: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class DatasetInsertParams -constructor( - private val datasetId: String, - private val events: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @@ -37,7 +50,7 @@ constructor( fun events(): List = events internal fun getBody(): DatasetInsertBody { - return DatasetInsertBody(events, additionalBodyProperties) + return DatasetInsertBody(events, additionalBodyProperties) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -45,24 +58,21 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @JsonDeserialize(builder = DatasetInsertBody.Builder::class) @NoAutoDetect - class DatasetInsertBody - internal constructor( - private val events: List?, - private val additionalProperties: Map, - ) { + class DatasetInsertBody internal constructor(private val events: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of dataset events to insert */ - @JsonProperty("events") fun events(): List? = events + @JsonProperty("events") + fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -71,24 +81,23 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is DatasetInsertBody && - this.events == other.events && - this.additionalProperties == other.additionalProperties + return other is DatasetInsertBody && + this.events == other.events && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(events, additionalProperties) + } + return hashCode } - override fun toString() = - "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetInsertBody{events=$events, additionalProperties=$additionalProperties}" companion object { @@ -106,7 +115,10 @@ constructor( } /** A list of dataset events to insert */ - @JsonProperty("events") fun events(events: List) = apply { this.events = events } + @JsonProperty("events") + fun events(events: List) = apply { + this.events = events + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -122,12 +134,9 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetInsertBody = - DatasetInsertBody( - checkNotNull(events) { "`events` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() - ) + fun build(): DatasetInsertBody = DatasetInsertBody(checkNotNull(events) { + "`events` is required but was not set" + }.toUnmodifiable(), additionalProperties.toUnmodifiable()) } } @@ -138,30 +147,29 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetInsertParams && - this.datasetId == other.datasetId && - this.events == other.events && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetInsertParams && + this.datasetId == other.datasetId && + this.events == other.events && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - events, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + events, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "DatasetInsertParams{datasetId=$datasetId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "DatasetInsertParams{datasetId=$datasetId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -188,7 +196,9 @@ constructor( } /** 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 { @@ -197,7 +207,9 @@ constructor( } /** A list of dataset events to insert */ - fun addEvent(event: Event) = apply { this.events.add(event) } + fun addEvent(event: Event) = apply { + this.events.add(event) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -237,7 +249,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -248,148 +262,124 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetInsertParams = - DatasetInsertParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - checkNotNull(events) { "`events` is required but was not set" }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetInsertParams = DatasetInsertParams( + checkNotNull(datasetId) { + "`datasetId` is required but was not set" + }, + checkNotNull(events) { + "`events` is required but was not set" + }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Event.Deserializer::class) @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertDatasetEventReplace: InsertDatasetEventReplace? = null, - private val insertDatasetEventMerge: InsertDatasetEventMerge? = null, - private val _json: JsonValue? = null, - ) { + class Event private constructor(private val insertDatasetEventReplace: InsertDatasetEventReplace? = null, private val insertDatasetEventMerge: InsertDatasetEventMerge? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun insertDatasetEventReplace(): InsertDatasetEventReplace? = insertDatasetEventReplace - fun insertDatasetEventMerge(): InsertDatasetEventMerge? = insertDatasetEventMerge fun isInsertDatasetEventReplace(): Boolean = insertDatasetEventReplace != null - fun isInsertDatasetEventMerge(): Boolean = insertDatasetEventMerge != null - fun asInsertDatasetEventReplace(): InsertDatasetEventReplace = - insertDatasetEventReplace.getOrThrow("insertDatasetEventReplace") - - fun asInsertDatasetEventMerge(): InsertDatasetEventMerge = - insertDatasetEventMerge.getOrThrow("insertDatasetEventMerge") + fun asInsertDatasetEventReplace(): InsertDatasetEventReplace = insertDatasetEventReplace.getOrThrow("insertDatasetEventReplace") + fun asInsertDatasetEventMerge(): InsertDatasetEventMerge = insertDatasetEventMerge.getOrThrow("insertDatasetEventMerge") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - insertDatasetEventReplace != null -> - visitor.visitInsertDatasetEventReplace(insertDatasetEventReplace) - insertDatasetEventMerge != null -> - visitor.visitInsertDatasetEventMerge(insertDatasetEventMerge) - else -> visitor.unknown(_json) - } + return when { + insertDatasetEventReplace != null -> visitor.visitInsertDatasetEventReplace(insertDatasetEventReplace) + insertDatasetEventMerge != null -> visitor.visitInsertDatasetEventMerge(insertDatasetEventMerge) + else -> visitor.unknown(_json) + } } fun validate(): Event = apply { if (!validated) { - if (insertDatasetEventReplace == null && insertDatasetEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertDatasetEventReplace?.validate() - insertDatasetEventMerge?.validate() - validated = true + if (insertDatasetEventReplace == null && insertDatasetEventMerge == null) { + throw BraintrustInvalidDataException("Unknown Event: $_json") + } + insertDatasetEventReplace?.validate() + insertDatasetEventMerge?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Event && - this.insertDatasetEventReplace == other.insertDatasetEventReplace && - this.insertDatasetEventMerge == other.insertDatasetEventMerge + return other is Event && + this.insertDatasetEventReplace == other.insertDatasetEventReplace && + this.insertDatasetEventMerge == other.insertDatasetEventMerge } override fun hashCode(): Int { - return Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) + return Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) } override fun toString(): String { - return when { - insertDatasetEventReplace != null -> - "Event{insertDatasetEventReplace=$insertDatasetEventReplace}" - insertDatasetEventMerge != null -> - "Event{insertDatasetEventMerge=$insertDatasetEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } + return when { + insertDatasetEventReplace != null -> "Event{insertDatasetEventReplace=$insertDatasetEventReplace}" + insertDatasetEventMerge != null -> "Event{insertDatasetEventMerge=$insertDatasetEventMerge}" + _json != null -> "Event{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Event") + } } companion object { - fun ofInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace) = - Event(insertDatasetEventReplace = insertDatasetEventReplace) + fun ofInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace) = Event(insertDatasetEventReplace = insertDatasetEventReplace) - fun ofInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge) = - Event(insertDatasetEventMerge = insertDatasetEventMerge) + fun ofInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge) = Event(insertDatasetEventMerge = insertDatasetEventMerge) } interface Visitor { - fun visitInsertDatasetEventReplace( - insertDatasetEventReplace: InsertDatasetEventReplace - ): T + fun visitInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace): T fun visitInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") + throw BraintrustInvalidDataException("Unknown Event: $json") } } class Deserializer : BaseDeserializer(Event::class) { override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertDatasetEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertDatasetEventMerge = it, _json = json) - } - - return Event(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Event(insertDatasetEventReplace = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Event(insertDatasetEventMerge = it, _json = json) + } + + return Event(_json = json) } } class Serializer : BaseSerializer(Event::class) { - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertDatasetEventReplace != null -> - generator.writeObject(value.insertDatasetEventReplace) - value.insertDatasetEventMerge != null -> - generator.writeObject(value.insertDatasetEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } + override fun serialize(value: Event, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.insertDatasetEventReplace != null -> generator.writeObject(value.insertDatasetEventReplace) + value.insertDatasetEventMerge != null -> generator.writeObject(value.insertDatasetEventMerge) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Event") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertResponse.kt deleted file mode 100755 index d15502e0..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetInsertResponse.kt +++ /dev/null @@ -1,121 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = DatasetInsertResponse.Builder::class) -@NoAutoDetect -class DatasetInsertResponse -private constructor( - private val rowIds: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - 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 - */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): DatasetInsertResponse = apply { - if (!validated) { - rowIds() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetInsertResponse && - this.rowIds == other.rowIds && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(rowIds, additionalProperties) - } - return hashCode - } - - override fun toString() = - "DatasetInsertResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var rowIds: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(datasetInsertResponse: DatasetInsertResponse) = apply { - this.rowIds = datasetInsertResponse.rowIds - additionalProperties(datasetInsertResponse.additionalProperties) - } - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - @JsonProperty("row_ids") - @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): DatasetInsertResponse = - DatasetInsertResponse( - rowIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt index ea761aa3..853b5ce5 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPage.kt @@ -2,97 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.services.blocking.DatasetService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class DatasetListPage -private constructor( - private val datasetService: DatasetService, - private val params: DatasetListParams, - private val response: Response, -) { +class DatasetListPage private constructor(private val datasetService: DatasetService, private val params: DatasetListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetListPage && - this.datasetService == other.datasetService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is DatasetListPage && + this.datasetService == other.datasetService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - datasetService, - params, - response, - ) + return Objects.hash( + datasetService, + params, + response, + ) } - override fun toString() = - "DatasetListPage{datasetService=$datasetService, params=$params, response=$response}" + override fun toString() = "DatasetListPage{datasetService=$datasetService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): DatasetListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): DatasetListPage? { - return getNextPageParams()?.let { datasetService.list(it) } + return getNextPageParams()?.let { + datasetService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(datasetService: DatasetService, params: DatasetListParams, response: Response) = - DatasetListPage( - datasetService, - params, - response, - ) + fun of(datasetService: DatasetService, params: DatasetListParams, response: Response) = DatasetListPage( + datasetService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -100,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "DatasetListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -153,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: DatasetListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: DatasetListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt index fb4348d9..18a201da 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListPageAsync.kt @@ -2,99 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.DatasetServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Dataset +import com.braintrustdata.api.services.async.DatasetServiceAsync -class DatasetListPageAsync -private constructor( - private val datasetService: DatasetServiceAsync, - private val params: DatasetListParams, - private val response: Response, -) { +class DatasetListPageAsync private constructor(private val datasetService: DatasetServiceAsync, private val params: DatasetListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetListPageAsync && - this.datasetService == other.datasetService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is DatasetListPageAsync && + this.datasetService == other.datasetService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - datasetService, - params, - response, - ) + return Objects.hash( + datasetService, + params, + response, + ) } - override fun toString() = - "DatasetListPageAsync{datasetService=$datasetService, params=$params, response=$response}" + override fun toString() = "DatasetListPageAsync{datasetService=$datasetService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): DatasetListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + DatasetListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + DatasetListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): DatasetListPageAsync? { - return getNextPageParams()?.let { datasetService.list(it) } + return getNextPageParams()?.let { + datasetService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(datasetService: DatasetServiceAsync, params: DatasetListParams, response: Response) = - DatasetListPageAsync( - datasetService, - params, - response, - ) + fun of(datasetService: DatasetServiceAsync, params: DatasetListParams, response: Response) = DatasetListPageAsync( + datasetService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -102,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "DatasetListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -155,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: DatasetListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: DatasetListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt index e0c99694..f8a6981f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetListParams.kt @@ -2,35 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class DatasetListParams constructor( + private val datasetName: String?, + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectId: String?, + private val projectName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class DatasetListParams -constructor( - private val datasetName: String?, - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectId: String?, - private val projectName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun datasetName(): String? = datasetName @@ -50,17 +67,33 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.datasetName?.let { params.put("dataset_name", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.datasetName?.let { + params.put("dataset_name", listOf(it.toString())) + } + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.projectId?.let { + params.put("project_id", listOf(it.toString())) + } + this.projectName?.let { + params.put("project_name", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -70,40 +103,39 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetListParams && - this.datasetName == other.datasetName && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is DatasetListParams && + this.datasetName == other.datasetName && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectId == other.projectId && + this.projectName == other.projectName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - datasetName, - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + datasetName, + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "DatasetListParams{datasetName=$datasetName, endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -140,55 +172,75 @@ constructor( } /** Name of the dataset to search for */ - fun datasetName(datasetName: String) = apply { this.datasetName = datasetName } + fun datasetName(datasetName: String) = apply { + this.datasetName = datasetName + } /** * Pagination cursor id. * - * For example, if the initial item in the last page you fetched had an id of `foo`, pass - * `ending_before=foo` to fetch the previous page. Note: you may only pass one of - * `starting_after` and `ending_before` + * For example, if the initial item in the last page you fetched had an 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: String) = apply { + this.projectName = projectName + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -228,84 +280,79 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): DatasetListParams = - DatasetListParams( - datasetName, - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): DatasetListParams = DatasetListParams( + datasetName, + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -322,38 +369,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt index d4143842..9d96d891 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class DatasetRetrieveParams -constructor( - private val datasetId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class DatasetRetrieveParams constructor(private val datasetId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun datasetId(): String = datasetId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetRetrieveParams && - this.datasetId == other.datasetId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is DatasetRetrieveParams && + this.datasetId == other.datasetId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - datasetId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + datasetId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "DatasetRetrieveParams{datasetId=$datasetId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "DatasetRetrieveParams{datasetId=$datasetId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** Dataset id */ - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = apply { + this.datasetId = datasetId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): DatasetRetrieveParams = - DatasetRetrieveParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): DatasetRetrieveParams = DatasetRetrieveParams( + checkNotNull(datasetId) { + "`datasetId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt index bb3a46b1..0cd9bf86 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeParams.kt @@ -2,17 +2,46 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class DatasetSummarizeParams -constructor( - private val datasetId: String, - private val summarizeData: Boolean?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, +class DatasetSummarizeParams constructor( + private val datasetId: String, + private val summarizeData: Boolean?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + ) { fun datasetId(): String = datasetId @@ -20,19 +49,21 @@ constructor( fun summarizeData(): Boolean? = summarizeData internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.summarizeData?.let { params.put("summarize_data", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.summarizeData?.let { + params.put("summarize_data", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +71,27 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetSummarizeParams && - this.datasetId == other.datasetId && - this.summarizeData == other.summarizeData && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is DatasetSummarizeParams && + this.datasetId == other.datasetId && + this.summarizeData == other.summarizeData && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - datasetId, - summarizeData, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + datasetId, + summarizeData, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "DatasetSummarizeParams{datasetId=$datasetId, summarizeData=$summarizeData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -86,12 +116,17 @@ constructor( } /** 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -131,14 +166,17 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): DatasetSummarizeParams = - DatasetSummarizeParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - summarizeData, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): DatasetSummarizeParams = DatasetSummarizeParams( + checkNotNull(datasetId) { + "`datasetId` is required but was not set" + }, + summarizeData, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponse.kt deleted file mode 100755 index 4893f947..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponse.kt +++ /dev/null @@ -1,298 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -/** Summary of a dataset */ -@JsonDeserialize(builder = DatasetSummarizeResponse.Builder::class) -@NoAutoDetect -class DatasetSummarizeResponse -private constructor( - private val projectName: JsonField, - private val datasetName: JsonField, - private val projectUrl: JsonField, - private val datasetUrl: JsonField, - private val dataSummary: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the project that the dataset belongs to */ - fun projectName(): String = projectName.getRequired("project_name") - - /** Name of the dataset */ - fun datasetName(): String = datasetName.getRequired("dataset_name") - - /** URL to the project's page in the Braintrust app */ - fun projectUrl(): String = projectUrl.getRequired("project_url") - - /** URL to the dataset's page in the Braintrust app */ - fun datasetUrl(): String = datasetUrl.getRequired("dataset_url") - - /** Summary of a dataset's data */ - fun dataSummary(): DataSummary? = dataSummary.getNullable("data_summary") - - /** Name of the project that the dataset belongs to */ - @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName - - /** Name of the dataset */ - @JsonProperty("dataset_name") @ExcludeMissing fun _datasetName() = datasetName - - /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") @ExcludeMissing fun _projectUrl() = projectUrl - - /** URL to the dataset's page in the Braintrust app */ - @JsonProperty("dataset_url") @ExcludeMissing fun _datasetUrl() = datasetUrl - - /** Summary of a dataset's data */ - @JsonProperty("data_summary") @ExcludeMissing fun _dataSummary() = dataSummary - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): DatasetSummarizeResponse = apply { - if (!validated) { - projectName() - datasetName() - projectUrl() - datasetUrl() - dataSummary()?.validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetSummarizeResponse && - this.projectName == other.projectName && - this.datasetName == other.datasetName && - this.projectUrl == other.projectUrl && - this.datasetUrl == other.datasetUrl && - this.dataSummary == other.dataSummary && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectName, - datasetName, - projectUrl, - datasetUrl, - dataSummary, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "DatasetSummarizeResponse{projectName=$projectName, datasetName=$datasetName, projectUrl=$projectUrl, datasetUrl=$datasetUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var projectName: JsonField = JsonMissing.of() - private var datasetName: JsonField = JsonMissing.of() - private var projectUrl: JsonField = JsonMissing.of() - private var datasetUrl: JsonField = JsonMissing.of() - private var dataSummary: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(datasetSummarizeResponse: DatasetSummarizeResponse) = apply { - this.projectName = datasetSummarizeResponse.projectName - this.datasetName = datasetSummarizeResponse.datasetName - this.projectUrl = datasetSummarizeResponse.projectUrl - this.datasetUrl = datasetSummarizeResponse.datasetUrl - this.dataSummary = datasetSummarizeResponse.dataSummary - additionalProperties(datasetSummarizeResponse.additionalProperties) - } - - /** Name of the project that the dataset belongs to */ - fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - - /** Name of the project that the dataset belongs to */ - @JsonProperty("project_name") - @ExcludeMissing - fun projectName(projectName: JsonField) = apply { this.projectName = projectName } - - /** Name of the dataset */ - fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) - - /** Name of the dataset */ - @JsonProperty("dataset_name") - @ExcludeMissing - fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } - - /** URL to the project's page in the Braintrust app */ - fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) - - /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") - @ExcludeMissing - fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } - - /** URL to the dataset's page in the Braintrust app */ - fun datasetUrl(datasetUrl: String) = datasetUrl(JsonField.of(datasetUrl)) - - /** URL to the dataset's page in the Braintrust app */ - @JsonProperty("dataset_url") - @ExcludeMissing - fun datasetUrl(datasetUrl: JsonField) = apply { this.datasetUrl = datasetUrl } - - /** Summary of a dataset's data */ - fun dataSummary(dataSummary: DataSummary) = dataSummary(JsonField.of(dataSummary)) - - /** Summary of a dataset's data */ - @JsonProperty("data_summary") - @ExcludeMissing - fun dataSummary(dataSummary: JsonField) = apply { - this.dataSummary = dataSummary - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): DatasetSummarizeResponse = - DatasetSummarizeResponse( - projectName, - datasetName, - projectUrl, - datasetUrl, - dataSummary, - additionalProperties.toUnmodifiable(), - ) - } - - /** Summary of a dataset's data */ - @JsonDeserialize(builder = DataSummary.Builder::class) - @NoAutoDetect - class DataSummary - private constructor( - private val totalRecords: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Total number of records in the dataset */ - fun totalRecords(): Long = totalRecords.getRequired("total_records") - - /** Total number of records in the dataset */ - @JsonProperty("total_records") @ExcludeMissing fun _totalRecords() = totalRecords - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): DataSummary = apply { - if (!validated) { - totalRecords() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DataSummary && - this.totalRecords == other.totalRecords && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(totalRecords, additionalProperties) - } - return hashCode - } - - override fun toString() = - "DataSummary{totalRecords=$totalRecords, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var totalRecords: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(dataSummary: DataSummary) = apply { - this.totalRecords = dataSummary.totalRecords - additionalProperties(dataSummary.additionalProperties) - } - - /** Total number of records in the dataset */ - fun totalRecords(totalRecords: Long) = totalRecords(JsonField.of(totalRecords)) - - /** Total number of records in the dataset */ - @JsonProperty("total_records") - @ExcludeMissing - fun totalRecords(totalRecords: JsonField) = apply { - this.totalRecords = totalRecords - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): DataSummary = - DataSummary(totalRecords, additionalProperties.toUnmodifiable()) - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt index ef13a994..a0034f7e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DatasetUpdateParams.kt @@ -2,26 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class DatasetUpdateParams constructor( + private val datasetId: String, + private val description: String?, + private val metadata: Metadata?, + private val name: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class DatasetUpdateParams -constructor( - private val datasetId: String, - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun datasetId(): String = datasetId @@ -33,12 +56,12 @@ constructor( fun name(): String? = name internal fun getBody(): DatasetUpdateBody { - return DatasetUpdateBody( - description, - metadata, - name, - additionalBodyProperties, - ) + return DatasetUpdateBody( + description, + metadata, + name, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -46,32 +69,35 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> datasetId - else -> "" - } + return when (index) { + 0 -> datasetId + else -> "" + } } @JsonDeserialize(builder = DatasetUpdateBody.Builder::class) @NoAutoDetect - class DatasetUpdateBody - internal constructor( - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val additionalProperties: Map, + class DatasetUpdateBody internal constructor( + private val description: String?, + private val metadata: Metadata?, + private val name: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Textual description of the dataset */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + @JsonProperty("metadata") + fun metadata(): Metadata? = metadata /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name @JsonAnyGetter @ExcludeMissing @@ -80,32 +106,30 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetUpdateBody && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is DatasetUpdateBody && + this.description == other.description && + this.metadata == other.metadata && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - description, - metadata, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + description, + metadata, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "DatasetUpdateBody{description=$description, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -128,14 +152,21 @@ constructor( /** Textual description of the dataset */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** User-controlled metadata about the dataset */ @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = apply { + this.metadata = metadata + } /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -151,13 +182,12 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): DatasetUpdateBody = - DatasetUpdateBody( - description, - metadata, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): DatasetUpdateBody = DatasetUpdateBody( + description, + metadata, + name, + additionalProperties.toUnmodifiable(), + ) } } @@ -168,34 +198,33 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DatasetUpdateParams && - this.datasetId == other.datasetId && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is DatasetUpdateParams && + this.datasetId == other.datasetId && + this.description == other.description && + this.metadata == other.metadata && + this.name == other.name && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - datasetId, - description, - metadata, - name, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + datasetId, + description, + metadata, + name, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "DatasetUpdateParams{datasetId=$datasetId, description=$description, metadata=$metadata, name=$name, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "DatasetUpdateParams{datasetId=$datasetId, description=$description, metadata=$metadata, name=$name, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -226,16 +255,24 @@ constructor( } /** 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 { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = apply { + this.metadata = metadata + } /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -275,7 +312,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -286,30 +325,27 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): DatasetUpdateParams = - DatasetUpdateParams( - checkNotNull(datasetId) { "`datasetId` is required but was not set" }, - description, - metadata, - name, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): DatasetUpdateParams = DatasetUpdateParams( + checkNotNull(datasetId) { + "`datasetId` is required but was not set" + }, + description, + metadata, + name, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** User-controlled metadata about the dataset */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var hashCode: Int = 0 @@ -320,18 +356,19 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DeleteView.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DeleteView.kt deleted file mode 100755 index b294fa0f..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/DeleteView.kt +++ /dev/null @@ -1,250 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = DeleteView.Builder::class) -@NoAutoDetect -class DeleteView -private constructor( - private val objectType: JsonField, - private val objectId: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The object type that the ACL applies to */ - fun objectType(): ObjectType? = objectType.getNullable("object_type") - - /** The id of the object the view applies to */ - fun objectId(): String = objectId.getRequired("object_id") - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType - - /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): DeleteView = apply { - if (!validated) { - objectType() - objectId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DeleteView && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "DeleteView{objectType=$objectType, objectId=$objectId, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(deleteView: DeleteView) = apply { - this.objectType = deleteView.objectType - this.objectId = deleteView.objectId - additionalProperties(deleteView.additionalProperties) - } - - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } - - /** The id of the object the view applies to */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** The id of the object the view applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): DeleteView = - DeleteView( - objectType, - objectId, - additionalProperties.toUnmodifiable(), - ) - } - - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val ORGANIZATION = ObjectType(JsonField.of("organization")) - - val PROJECT = ObjectType(JsonField.of("project")) - - val EXPERIMENT = ObjectType(JsonField.of("experiment")) - - val DATASET = ObjectType(JsonField.of("dataset")) - - val PROMPT = ObjectType(JsonField.of("prompt")) - - val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) - - val GROUP = ObjectType(JsonField.of("group")) - - val ROLE = ObjectType(JsonField.of("role")) - - val ORG_MEMBER = ObjectType(JsonField.of("org_member")) - - val PROJECT_LOG = ObjectType(JsonField.of("project_log")) - - val ORG_PROJECT = ObjectType(JsonField.of("org_project")) - - fun of(value: String) = ObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt index 1ca9c8d8..1b2c858a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Experiment.kt @@ -2,38 +2,56 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Experiment.Builder::class) @NoAutoDetect -class Experiment -private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val name: JsonField, - private val description: JsonField, - private val created: JsonField, - private val repoInfo: JsonField, - private val commit: JsonField, - private val baseExpId: JsonField, - private val deletedAt: JsonField, - private val datasetId: JsonField, - private val datasetVersion: JsonField, - private val public_: JsonField, - private val userId: JsonField, - private val metadata: JsonField, - private val additionalProperties: Map, +class Experiment private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val name: JsonField, + private val description: JsonField, + private val created: JsonField, + private val repoInfo: JsonField, + private val commit: JsonField, + private val baseExpId: JsonField, + private val deletedAt: JsonField, + private val datasetId: JsonField, + private val datasetVersion: JsonField, + private val public_: JsonField, + private val userId: JsonField, + private val metadata: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -67,18 +85,21 @@ private constructor( /** Date of experiment deletion, or null if the experiment is still active */ fun deletedAt(): OffsetDateTime? = deletedAt.getNullable("deleted_at") - /** 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(): String? = 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(): String? = datasetVersion.getNullable("dataset_version") /** - * 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") @@ -89,52 +110,83 @@ private constructor( fun metadata(): Metadata? = metadata.getNullable("metadata") /** Unique identifier for the experiment */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId() = projectId /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Textual description of the experiment */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description() = description /** Date of experiment creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo() = repoInfo + @JsonProperty("repo_info") + @ExcludeMissing + fun _repoInfo() = repoInfo /** Commit, taken directly from `repo_info.commit` */ - @JsonProperty("commit") @ExcludeMissing fun _commit() = commit + @JsonProperty("commit") + @ExcludeMissing + fun _commit() = commit /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId() = baseExpId + @JsonProperty("base_exp_id") + @ExcludeMissing + fun _baseExpId() = baseExpId /** Date of experiment deletion, or null if the experiment is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt() = deletedAt - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a + * dataset + */ + @JsonProperty("dataset_id") + @ExcludeMissing + fun _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. */ - @JsonProperty("dataset_version") @ExcludeMissing fun _datasetVersion() = datasetVersion + @JsonProperty("dataset_version") + @ExcludeMissing + fun _datasetVersion() = datasetVersion /** - * 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_() = public_ + @JsonProperty("public") + @ExcludeMissing + fun _public_() = public_ /** Identifies the user who created the experiment */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata @JsonAnyGetter @ExcludeMissing @@ -142,75 +194,73 @@ private constructor( fun validate(): Experiment = apply { if (!validated) { - id() - projectId() - name() - description() - created() - repoInfo()?.validate() - commit() - baseExpId() - deletedAt() - datasetId() - datasetVersion() - public_() - userId() - metadata()?.validate() - validated = true + id() + projectId() + name() + description() + created() + repoInfo()?.validate() + commit() + baseExpId() + deletedAt() + datasetId() + datasetVersion() + public_() + userId() + metadata()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Experiment && - this.id == other.id && - this.projectId == other.projectId && - this.name == other.name && - this.description == other.description && - this.created == other.created && - this.repoInfo == other.repoInfo && - this.commit == other.commit && - this.baseExpId == other.baseExpId && - this.deletedAt == other.deletedAt && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.public_ == other.public_ && - this.userId == other.userId && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Experiment && + this.id == other.id && + this.projectId == other.projectId && + this.name == other.name && + this.description == other.description && + this.created == other.created && + this.repoInfo == other.repoInfo && + this.commit == other.commit && + this.baseExpId == other.baseExpId && + this.deletedAt == other.deletedAt && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.public_ == other.public_ && + this.userId == other.userId && + this.metadata == other.metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - projectId, - name, - description, - created, - repoInfo, - commit, - baseExpId, - deletedAt, - datasetId, - datasetVersion, - public_, - userId, - metadata, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + projectId, + name, + description, + created, + repoInfo, + commit, + baseExpId, + deletedAt, + datasetId, + datasetVersion, + public_, + userId, + metadata, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Experiment{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, repoInfo=$repoInfo, commit=$commit, baseExpId=$baseExpId, deletedAt=$deletedAt, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = "Experiment{id=$id, projectId=$projectId, name=$name, description=$description, created=$created, repoInfo=$repoInfo, commit=$commit, baseExpId=$baseExpId, deletedAt=$deletedAt, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, userId=$userId, metadata=$metadata, additionalProperties=$additionalProperties}" companion object { @@ -257,7 +307,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the experiment */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -265,7 +319,9 @@ private constructor( /** Unique identifier for the project that the experiment belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } /** Name of the experiment. Within a project, experiment names are unique */ fun name(name: String) = name(JsonField.of(name)) @@ -273,7 +329,9 @@ private constructor( /** Name of the experiment. Within a project, experiment names are unique */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } /** Textual description of the experiment */ fun description(description: String) = description(JsonField.of(description)) @@ -281,7 +339,9 @@ private constructor( /** Textual description of the experiment */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } /** Date of experiment creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -289,7 +349,9 @@ private constructor( /** Date of experiment creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** Metadata about the state of the repo when the experiment was created */ fun repoInfo(repoInfo: RepoInfo) = repoInfo(JsonField.of(repoInfo)) @@ -297,7 +359,9 @@ private constructor( /** Metadata about the state of the repo when the experiment was created */ @JsonProperty("repo_info") @ExcludeMissing - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: JsonField) = apply { + this.repoInfo = repoInfo + } /** Commit, taken directly from `repo_info.commit` */ fun commit(commit: String) = commit(JsonField.of(commit)) @@ -305,7 +369,9 @@ private constructor( /** Commit, taken directly from `repo_info.commit` */ @JsonProperty("commit") @ExcludeMissing - fun commit(commit: JsonField) = apply { this.commit = commit } + fun commit(commit: JsonField) = apply { + this.commit = commit + } /** Id of default base experiment to compare against when viewing this experiment */ fun baseExpId(baseExpId: String) = baseExpId(JsonField.of(baseExpId)) @@ -313,7 +379,9 @@ private constructor( /** Id of default base experiment to compare against when viewing this experiment */ @JsonProperty("base_exp_id") @ExcludeMissing - fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: JsonField) = apply { + this.baseExpId = baseExpId + } /** Date of experiment deletion, or null if the experiment is still active */ fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) @@ -321,29 +389,35 @@ private constructor( /** Date of experiment deletion, or null if the experiment is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } /** - * 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.of(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 */ @JsonProperty("dataset_id") @ExcludeMissing - 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.of(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. */ @JsonProperty("dataset_version") @ExcludeMissing @@ -352,18 +426,20 @@ private constructor( } /** - * 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 */ @JsonProperty("public") @ExcludeMissing - fun public_(public_: JsonField) = apply { this.public_ = public_ } + fun public_(public_: JsonField) = apply { + this.public_ = public_ + } /** Identifies the user who created the experiment */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -371,7 +447,9 @@ private constructor( /** Identifies the user who created the experiment */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } /** User-controlled metadata about the experiment */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) @@ -379,7 +457,9 @@ private constructor( /** User-controlled metadata about the experiment */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -395,33 +475,29 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Experiment = - Experiment( - id, - projectId, - name, - description, - created, - repoInfo, - commit, - baseExpId, - deletedAt, - datasetId, - datasetVersion, - public_, - userId, - metadata, - additionalProperties.toUnmodifiable(), - ) + fun build(): Experiment = Experiment( + id, + projectId, + name, + description, + created, + repoInfo, + commit, + baseExpId, + deletedAt, + datasetId, + datasetVersion, + public_, + userId, + metadata, + additionalProperties.toUnmodifiable(), + ) } /** User-controlled metadata about the experiment */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -433,25 +509,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt index e43409be..3b5f501d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentCreateParams.kt @@ -2,32 +2,55 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ExperimentCreateParams constructor( + private val projectId: String, + private val baseExpId: String?, + private val datasetId: String?, + private val datasetVersion: String?, + private val description: String?, + private val ensureNew: Boolean?, + private val metadata: Metadata?, + private val name: String?, + private val public_: Boolean?, + private val repoInfo: RepoInfo?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ExperimentCreateParams -constructor( - private val projectId: String, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val ensureNew: Boolean?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -51,19 +74,19 @@ constructor( fun repoInfo(): RepoInfo? = repoInfo internal fun getBody(): ExperimentCreateBody { - return ExperimentCreateBody( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalBodyProperties, - ) + return ExperimentCreateBody( + projectId, + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -72,64 +95,76 @@ constructor( @JsonDeserialize(builder = ExperimentCreateBody.Builder::class) @NoAutoDetect - class ExperimentCreateBody - internal constructor( - private val projectId: String?, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val ensureNew: Boolean?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalProperties: Map, + class ExperimentCreateBody internal constructor( + private val projectId: String?, + private val baseExpId: String?, + private val datasetId: String?, + private val datasetVersion: String?, + private val description: String?, + private val ensureNew: Boolean?, + private val metadata: Metadata?, + private val name: String?, + private val public_: Boolean?, + private val repoInfo: RepoInfo?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") + fun projectId(): String? = projectId /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") fun baseExpId(): String? = baseExpId + @JsonProperty("base_exp_id") + fun baseExpId(): String? = 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") fun datasetId(): String? = datasetId + @JsonProperty("dataset_id") + fun datasetId(): String? = 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") fun datasetVersion(): String? = datasetVersion + @JsonProperty("dataset_version") + fun datasetVersion(): String? = datasetVersion /** Textual description of the experiment */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = 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") fun ensureNew(): Boolean? = ensureNew + @JsonProperty("ensure_new") + fun ensureNew(): Boolean? = ensureNew /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + @JsonProperty("metadata") + fun metadata(): Metadata? = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = 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") fun public_(): Boolean? = public_ + @JsonProperty("public") + fun public_(): Boolean? = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") fun repoInfo(): RepoInfo? = repoInfo + @JsonProperty("repo_info") + fun repoInfo(): RepoInfo? = repoInfo @JsonAnyGetter @ExcludeMissing @@ -138,46 +173,44 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentCreateBody && - this.projectId == other.projectId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.ensureNew == other.ensureNew && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ExperimentCreateBody && + this.projectId == other.projectId && + this.baseExpId == other.baseExpId && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.description == other.description && + this.ensureNew == other.ensureNew && + this.metadata == other.metadata && + this.name == other.name && + this.public_ == other.public_ && + this.repoInfo == other.repoInfo && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + projectId, + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + override fun toString() = "ExperimentCreateBody{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" companion object { @@ -214,22 +247,28 @@ constructor( /** Unique identifier for the project that the experiment belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Id of default base experiment to compare against when viewing this experiment */ @JsonProperty("base_exp_id") - fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: String) = apply { + this.baseExpId = baseExpId + } /** * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ @JsonProperty("dataset_id") - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = 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. */ @JsonProperty("dataset_version") fun datasetVersion(datasetVersion: String) = apply { @@ -238,32 +277,47 @@ constructor( /** Textual description of the experiment */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = 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. */ @JsonProperty("ensure_new") - fun ensureNew(ensureNew: Boolean) = apply { this.ensureNew = ensureNew } + fun ensureNew(ensureNew: Boolean) = apply { + this.ensureNew = ensureNew + } /** User-controlled metadata about the experiment */ @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = apply { + this.metadata = metadata + } /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = 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 */ - @JsonProperty("public") fun public_(public_: Boolean) = apply { this.public_ = public_ } + @JsonProperty("public") + fun public_(public_: Boolean) = apply { + this.public_ = public_ + } /** Metadata about the state of the repo when the experiment was created */ @JsonProperty("repo_info") - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: RepoInfo) = apply { + this.repoInfo = repoInfo + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -279,20 +333,21 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentCreateBody = - ExperimentCreateBody( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalProperties.toUnmodifiable(), - ) + fun build(): ExperimentCreateBody = ExperimentCreateBody( + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalProperties.toUnmodifiable(), + ) } } @@ -303,46 +358,45 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentCreateParams && - this.projectId == other.projectId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.ensureNew == other.ensureNew && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentCreateParams && + this.projectId == other.projectId && + this.baseExpId == other.baseExpId && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.description == other.description && + this.ensureNew == other.ensureNew && + this.metadata == other.metadata && + this.name == other.name && + this.public_ == other.public_ && + this.repoInfo == other.repoInfo && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ExperimentCreateParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ExperimentCreateParams{projectId=$projectId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, ensureNew=$ensureNew, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -385,46 +439,68 @@ constructor( } /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: String) = apply { + this.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 { this.datasetId = datasetId } + fun datasetId(datasetId: String) = 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) = apply { this.datasetVersion = datasetVersion } + fun datasetVersion(datasetVersion: String) = apply { + this.datasetVersion = datasetVersion + } /** Textual description of the experiment */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = 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) = apply { this.ensureNew = ensureNew } + fun ensureNew(ensureNew: Boolean) = apply { + this.ensureNew = ensureNew + } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = apply { + this.metadata = metadata + } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = 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) = apply { this.public_ = public_ } + fun public_(public_: Boolean) = apply { + this.public_ = public_ + } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: RepoInfo) = apply { + this.repoInfo = repoInfo + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -464,7 +540,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -475,36 +553,33 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentCreateParams = - ExperimentCreateParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - baseExpId, - datasetId, - datasetVersion, - description, - ensureNew, - metadata, - name, - public_, - repoInfo, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentCreateParams = ExperimentCreateParams( + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + baseExpId, + datasetId, + datasetVersion, + description, + ensureNew, + metadata, + name, + public_, + repoInfo, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** User-controlled metadata about the experiment */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var hashCode: Int = 0 @@ -515,18 +590,19 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt index f406c710..854e57a8 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ExperimentDeleteParams -constructor( - private val experimentId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ExperimentDeleteParams constructor( + private val experimentId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun experimentId(): String = experimentId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentDeleteParams && - this.experimentId == other.experimentId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentDeleteParams && + this.experimentId == other.experimentId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ExperimentDeleteParams{experimentId=$experimentId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ExperimentDeleteParams{experimentId=$experimentId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = apply { + this.experimentId = experimentId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ExperimentDeleteParams = - ExperimentDeleteParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ExperimentDeleteParams = ExperimentDeleteParams( + checkNotNull(experimentId) { + "`experimentId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt index 797e1b33..8e4605f4 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentEvent.kt @@ -2,46 +2,61 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ExperimentEvent.Builder::class) @NoAutoDetect -class ExperimentEvent -private constructor( - private val id: JsonField, - private val datasetRecordId: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val experimentId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val additionalProperties: Map, +class ExperimentEvent private constructor( + private val id: JsonField, + private val datasetRecordId: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val projectId: JsonField, + private val experimentId: JsonField, + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanId: JsonField, + private val spanParents: JsonField>, + private val rootSpanId: JsonField, + private val spanAttributes: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -49,21 +64,22 @@ private constructor( private var hashCode: Int = 0 /** - * 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") /** - * 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(): String? = datasetRecordId.getNullable("dataset_record_id") /** - * The transaction id of an event is unique to the network operation that processed the event - * insertion. Transaction ids are monotonically increasing over time and can be used to retrieve - * 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") @@ -77,29 +93,31 @@ private constructor( fun experimentId(): String = experimentId.getRequired("experiment_id") /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable + * object). Later on, Braintrust will use the `input` to know whether two test + * cases are the same between experiments, so they should not contain + * experiment-specific state. A simple rule of thumb is that if you run the same + * experiment twice, the `input` should be identical */ fun input(): JsonValue = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ fun expected(): JsonValue = expected @@ -107,22 +125,23 @@ private constructor( fun error(): JsonValue = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * 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.getNullable("scores") /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else 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.getNullable("metadata") @@ -130,29 +149,32 @@ private constructor( fun tags(): List? = tags.getNullable("tags") /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * 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.getNullable("metrics") /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * 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.getNullable("context") /** - * 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") /** - * 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(): List? = spanParents.getNullable("span_parents") @@ -163,118 +185,163 @@ private constructor( fun spanAttributes(): SpanAttributes? = spanAttributes.getNullable("span_attributes") /** - * 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() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId + @JsonProperty("dataset_record_id") + @ExcludeMissing + fun _datasetRecordId() = datasetRecordId /** - * 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() = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId() = _xactId /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId() = projectId /** Unique identifier for the experiment */ - @JsonProperty("experiment_id") @ExcludeMissing fun _experimentId() = experimentId + @JsonProperty("experiment_id") + @ExcludeMissing + fun _experimentId() = experimentId /** - * 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() = input + @JsonProperty("input") + @ExcludeMissing + fun _input() = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - @JsonProperty("output") @ExcludeMissing fun _output() = output + @JsonProperty("output") + @ExcludeMissing + fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error + @JsonProperty("error") + @ExcludeMissing + fun _error() = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores() = scores /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics() = metrics /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - @JsonProperty("context") @ExcludeMissing fun _context() = context + @JsonProperty("context") + @ExcludeMissing + fun _context() = context /** - * 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() = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId() = spanId /** - * 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() = spanParents + @JsonProperty("span_parents") + @ExcludeMissing + fun _spanParents() = spanParents /** The `span_id` of the root of the trace this experiment event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId() = rootSpanId /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") + @ExcludeMissing + fun _spanAttributes() = spanAttributes @JsonAnyGetter @ExcludeMissing @@ -282,90 +349,88 @@ private constructor( fun validate(): ExperimentEvent = apply { if (!validated) { - id() - datasetRecordId() - _xactId() - created() - projectId() - experimentId() - input() - output() - expected() - error() - scores()?.validate() - metadata()?.validate() - tags() - metrics()?.validate() - context()?.validate() - spanId() - spanParents() - rootSpanId() - spanAttributes()?.validate() - validated = true + id() + datasetRecordId() + _xactId() + created() + projectId() + experimentId() + input() + output() + expected() + error() + scores()?.validate() + metadata()?.validate() + tags() + metrics()?.validate() + context()?.validate() + spanId() + spanParents() + rootSpanId() + spanAttributes()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentEvent && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.experimentId == other.experimentId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ExperimentEvent && + this.id == other.id && + this.datasetRecordId == other.datasetRecordId && + this._xactId == other._xactId && + this.created == other.created && + this.projectId == other.projectId && + this.experimentId == other.experimentId && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanId == other.spanId && + this.spanParents == other.spanParents && + this.rootSpanId == other.rootSpanId && + this.spanAttributes == other.spanAttributes && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + datasetRecordId, + _xactId, + created, + projectId, + experimentId, + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanId, + spanParents, + rootSpanId, + spanAttributes, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ExperimentEvent{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" + override fun toString() = "ExperimentEvent{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" companion object { @@ -419,27 +484,30 @@ private constructor( } /** - * 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 */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String) = - datasetRecordId(JsonField.of(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String) = datasetRecordId(JsonField.of(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * 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 @@ -448,20 +516,24 @@ private constructor( } /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the experiment (see the `version` parameter) + * 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) */ @JsonProperty("_xact_id") @ExcludeMissing - 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)) @@ -469,7 +541,9 @@ private constructor( /** The timestamp the experiment event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** Unique identifier for the project that the experiment belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -477,7 +551,9 @@ private constructor( /** Unique identifier for the project that the experiment belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } /** Unique identifier for the experiment */ fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) @@ -490,86 +566,102 @@ private constructor( } /** - * 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(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { + this.input = input + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = apply { + this.output = output + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** The error that occurred, if any. */ @JsonProperty("error") @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = apply { + this.error = error + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = apply { + this.scores = scores + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -577,65 +669,79 @@ private constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = apply { + this.metrics = metrics + } /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Context) = context(JsonField.of(context)) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = apply { + this.context = context + } /** - * 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 */ @JsonProperty("span_id") @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = apply { + this.spanId = spanId + } /** - * 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.of(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 */ @JsonProperty("span_parents") @ExcludeMissing @@ -649,11 +755,12 @@ private constructor( /** The `span_id` of the root of the trace this experiment event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = apply { + this.rootSpanId = rootSpanId + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -676,44 +783,44 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentEvent = - ExperimentEvent( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - error, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanId, - spanParents.map { it.toUnmodifiable() }, - rootSpanId, - spanAttributes, - additionalProperties.toUnmodifiable(), - ) + fun build(): ExperimentEvent = ExperimentEvent( + id, + datasetRecordId, + _xactId, + created, + projectId, + experimentId, + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanId, + spanParents.map { it.toUnmodifiable() }, + rootSpanId, + spanAttributes, + additionalProperties.toUnmodifiable(), + ) } /** - * 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 */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, + class Context private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -735,10 +842,14 @@ private constructor( fun _callerFunctionname() = callerFunctionname /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename() = callerFilename /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -746,42 +857,40 @@ private constructor( fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { @@ -803,8 +912,7 @@ private constructor( } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -814,8 +922,7 @@ private constructor( } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -848,29 +955,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun build(): Context = Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else 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 */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -882,25 +985,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" @@ -937,20 +1041,20 @@ 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 */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, + class Metrics private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -958,26 +1062,26 @@ private constructor( private var hashCode: Int = 0 /** - * 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(): Double? = start.getNullable("start") /** - * 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(): Double? = 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(): Long? = promptTokens.getNullable("prompt_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) */ fun completionTokens(): Long? = completionTokens.getNullable("completion_tokens") @@ -985,33 +1089,41 @@ private constructor( fun tokens(): Long? = tokens.getNullable("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 */ - @JsonProperty("start") @ExcludeMissing fun _start() = start + @JsonProperty("start") + @ExcludeMissing + fun _start() = start /** - * 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() = end + @JsonProperty("end") + @ExcludeMissing + fun _end() = end /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens() = promptTokens /** - * 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() = completionTokens /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -1019,48 +1131,46 @@ private constructor( fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { @@ -1086,42 +1196,46 @@ private constructor( } /** - * 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.of(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 */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = apply { + this.start = start + } /** - * 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.of(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 */ @JsonProperty("end") @ExcludeMissing - 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.of(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) */ @JsonProperty("prompt_tokens") @ExcludeMissing @@ -1130,15 +1244,14 @@ private constructor( } /** - * 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.of(completionTokens)) + fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing @@ -1152,7 +1265,9 @@ private constructor( /** The total number of tokens in the input and output of the experiment event. */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = apply { + this.tokens = tokens + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1168,33 +1283,30 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun build(): Metrics = Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * 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 */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { + class Scores private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1206,25 +1318,26 @@ private constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" @@ -1263,12 +1376,7 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { + class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1281,10 +1389,14 @@ private constructor( fun type(): Type? = type.getNullable("type") /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1292,39 +1404,37 @@ private constructor( fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1349,7 +1459,9 @@ private constructor( /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - 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.of(type)) @@ -1357,7 +1469,9 @@ private constructor( /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1373,28 +1487,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): SpanAttributes = SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1437,27 +1548,25 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt index 9fd90785..f6dfeb30 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParams.kt @@ -2,24 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ExperimentFeedbackParams constructor( + private val experimentId: String, + private val feedback: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ExperimentFeedbackParams -constructor( - private val experimentId: String, - private val feedback: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @@ -27,7 +50,7 @@ constructor( fun feedback(): List = feedback internal fun getBody(): ExperimentFeedbackBody { - return ExperimentFeedbackBody(feedback, additionalBodyProperties) + return ExperimentFeedbackBody(feedback, additionalBodyProperties) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -35,24 +58,21 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @JsonDeserialize(builder = ExperimentFeedbackBody.Builder::class) @NoAutoDetect - class ExperimentFeedbackBody - internal constructor( - private val feedback: List?, - private val additionalProperties: Map, - ) { + class ExperimentFeedbackBody internal constructor(private val feedback: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of experiment feedback items */ - @JsonProperty("feedback") fun feedback(): List? = feedback + @JsonProperty("feedback") + fun feedback(): List? = feedback @JsonAnyGetter @ExcludeMissing @@ -61,24 +81,23 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ExperimentFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties + return other is ExperimentFeedbackBody && + this.feedback == other.feedback && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(feedback, additionalProperties) + } + return hashCode } - override fun toString() = - "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = "ExperimentFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" companion object { @@ -115,12 +134,9 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentFeedbackBody = - ExperimentFeedbackBody( - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() - ) + fun build(): ExperimentFeedbackBody = ExperimentFeedbackBody(checkNotNull(feedback) { + "`feedback` is required but was not set" + }.toUnmodifiable(), additionalProperties.toUnmodifiable()) } } @@ -131,30 +147,29 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFeedbackParams && - this.experimentId == other.experimentId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentFeedbackParams && + this.experimentId == other.experimentId && + this.feedback == other.feedback && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + feedback, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ExperimentFeedbackParams{experimentId=$experimentId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ExperimentFeedbackParams{experimentId=$experimentId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -181,7 +196,9 @@ constructor( } /** 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 { @@ -190,7 +207,9 @@ constructor( } /** A list of experiment feedback items */ - fun addFeedback(feedback: FeedbackExperimentItem) = apply { this.feedback.add(feedback) } + fun addFeedback(feedback: FeedbackExperimentItem) = apply { + this.feedback.add(feedback) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -230,7 +249,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -241,19 +262,20 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentFeedbackParams = - ExperimentFeedbackParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentFeedbackParams = ExperimentFeedbackParams( + checkNotNull(experimentId) { + "`experimentId` is required but was not set" + }, + checkNotNull(feedback) { + "`feedback` is required but was not set" + }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt index 5c58fe6e..380d5d96 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchParams.kt @@ -2,20 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ExperimentFetchParams -constructor( - private val experimentId: String, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, +class ExperimentFetchParams constructor( + private val experimentId: String, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + ) { fun experimentId(): String = experimentId @@ -29,22 +58,30 @@ constructor( fun version(): String? = version internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { params.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } - this.version?.let { params.put("version", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.maxRootSpanId?.let { + params.put("max_root_span_id", listOf(it.toString())) + } + this.maxXactId?.let { + params.put("max_xact_id", listOf(it.toString())) + } + this.version?.let { + params.put("version", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -52,34 +89,33 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchParams && - this.experimentId == other.experimentId && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ExperimentFetchParams && + this.experimentId == other.experimentId && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - experimentId, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + experimentId, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ExperimentFetchParams{experimentId=$experimentId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -110,60 +146,72 @@ constructor( } /** 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 + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the 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 maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String) = 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) = apply { this.version = version } + fun version(version: String) = apply { + this.version = version + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -203,17 +251,20 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): ExperimentFetchParams = - ExperimentFetchParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): ExperimentFetchParams = ExperimentFetchParams( + checkNotNull(experimentId) { + "`experimentId` is required but was not set" + }, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt index ea8c04bf..2fff866c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParams.kt @@ -2,29 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ExperimentFetchPostParams constructor( + private val experimentId: String, + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ExperimentFetchPostParams -constructor( - private val experimentId: String, - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @@ -42,15 +65,15 @@ constructor( fun version(): String? = version internal fun getBody(): ExperimentFetchPostBody { - return ExperimentFetchPostBody( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalBodyProperties, - ) + return ExperimentFetchPostBody( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -58,98 +81,106 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @JsonDeserialize(builder = ExperimentFetchPostBody.Builder::class) @NoAutoDetect - class ExperimentFetchPostBody - internal constructor( - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalProperties: Map, + class ExperimentFetchPostBody internal constructor( + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * 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") fun cursor(): String? = cursor + @JsonProperty("cursor") + fun cursor(): String? = cursor /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ - @JsonProperty("filters") fun filters(): List? = filters + @JsonProperty("filters") + fun filters(): List? = filters /** * 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. */ - @JsonProperty("limit") fun limit(): Long? = limit + @JsonProperty("limit") + fun limit(): Long? = 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") fun maxRootSpanId(): String? = maxRootSpanId + @JsonProperty("max_root_span_id") + fun maxRootSpanId(): String? = 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") fun maxXactId(): String? = maxXactId + @JsonProperty("max_xact_id") + fun maxXactId(): String? = 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") fun version(): String? = version + @JsonProperty("version") + fun version(): String? = version @JsonAnyGetter @ExcludeMissing @@ -158,38 +189,36 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchPostBody && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ExperimentFetchPostBody && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "ExperimentFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -217,80 +246,96 @@ constructor( } /** - * 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") fun cursor(cursor: String) = apply { this.cursor = cursor } + @JsonProperty("cursor") + fun cursor(cursor: String) = apply { + this.cursor = cursor + } /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters - * are supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } + fun filters(filters: List) = apply { + this.filters = filters + } /** * 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. */ - @JsonProperty("limit") fun limit(limit: Long) = apply { this.limit = limit } + @JsonProperty("limit") + fun limit(limit: Long) = 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. */ @JsonProperty("max_root_span_id") - 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. */ @JsonProperty("max_xact_id") - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String) = 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. */ - @JsonProperty("version") fun version(version: String) = apply { this.version = version } + @JsonProperty("version") + fun version(version: String) = apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -306,16 +351,15 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentFetchPostBody = - ExperimentFetchPostBody( - cursor, - filters?.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): ExperimentFetchPostBody = ExperimentFetchPostBody( + cursor, + filters?.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toUnmodifiable(), + ) } } @@ -326,40 +370,39 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchPostParams && - this.experimentId == other.experimentId && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentFetchPostParams && + this.experimentId == other.experimentId && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ExperimentFetchPostParams{experimentId=$experimentId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -396,24 +439,28 @@ constructor( } /** 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 { this.cursor = cursor } + fun cursor(cursor: String) = apply { + this.cursor = cursor + } /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ fun filters(filters: List) = apply { this.filters.clear() @@ -421,67 +468,79 @@ constructor( } /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ - fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } + fun addFilter(filter: PathLookupFilter) = apply { + this.filters.add(filter) + } /** * 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 + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the 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 maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String) = 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) = apply { this.version = version } + fun version(version: String) = apply { + this.version = version + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -521,7 +580,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -532,23 +593,23 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentFetchPostParams = - ExperimentFetchPostParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - cursor, - if (filters.size == 0) null else filters.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentFetchPostParams = ExperimentFetchPostParams( + checkNotNull(experimentId) { + "`experimentId` is required but was not set" + }, + cursor, + if(filters.size == 0) null else filters.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponse.kt deleted file mode 100755 index c04bd1d5..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponse.kt +++ /dev/null @@ -1,1601 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects - -@JsonDeserialize(builder = ExperimentFetchPostResponse.Builder::class) -@NoAutoDetect -class ExperimentFetchPostResponse -private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of fetched events */ - fun events(): List = events.getRequired("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. - */ - fun cursor(): String? = cursor.getNullable("cursor") - - /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = 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. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ExperimentFetchPostResponse = apply { - if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchPostResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ExperimentFetchPostResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var events: JsonField> = JsonMissing.of() - private var cursor: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(experimentFetchPostResponse: ExperimentFetchPostResponse) = apply { - this.events = experimentFetchPostResponse.events - this.cursor = experimentFetchPostResponse.cursor - additionalProperties(experimentFetchPostResponse.additionalProperties) - } - - /** A list of fetched events */ - fun events(events: List) = events(JsonField.of(events)) - - /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } - - /** - * Pagination cursor - * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. - */ - fun cursor(cursor: String) = cursor(JsonField.of(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. - */ - @JsonProperty("cursor") - @ExcludeMissing - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ExperimentFetchPostResponse = - ExperimentFetchPostResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Event.Builder::class) - @NoAutoDetect - class Event - private constructor( - private val id: JsonField, - private val datasetRecordId: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val experimentId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(): String = id.getRequired("id") - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(): String? = datasetRecordId.getNullable("dataset_record_id") - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the experiment (see the `version` parameter) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** The timestamp the experiment event was created */ - fun created(): OffsetDateTime = created.getRequired("created") - - /** Unique identifier for the project that the experiment belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** Unique identifier for the experiment */ - fun experimentId(): String = experimentId.getRequired("experiment_id") - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models - */ - fun expected(): JsonValue = expected - - /** - * 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.getNullable("scores") - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** A list of tags to log */ - fun tags(): List? = tags.getNullable("tags") - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - fun metrics(): Metrics? = metrics.getNullable("metrics") - - /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event - */ - fun context(): Context? = context.getNullable("context") - - /** - * 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") - - /** - * 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(): List? = spanParents.getNullable("span_parents") - - /** The `span_id` of the root of the trace this experiment event belongs to */ - fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): SpanAttributes? = spanAttributes.getNullable("span_attributes") - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the experiment (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** Unique identifier for the experiment */ - @JsonProperty("experiment_id") @ExcludeMissing fun _experimentId() = experimentId - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** - * 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() = spanId - - /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans - */ - @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents - - /** The `span_id` of the root of the trace this experiment event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Event = apply { - if (!validated) { - id() - datasetRecordId() - _xactId() - created() - projectId() - experimentId() - input() - output() - expected() - scores()?.validate() - metadata()?.validate() - tags() - metrics()?.validate() - context()?.validate() - spanId() - spanParents() - rootSpanId() - spanAttributes()?.validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.experimentId == other.experimentId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Event{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var datasetRecordId: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var experimentId: JsonField = JsonMissing.of() - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() - private var spanParents: JsonField> = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(event: Event) = apply { - this.id = event.id - this.datasetRecordId = event.datasetRecordId - this._xactId = event._xactId - this.created = event.created - this.projectId = event.projectId - this.experimentId = event.experimentId - this.input = event.input - this.output = event.output - this.expected = event.expected - this.scores = event.scores - this.metadata = event.metadata - this.tags = event.tags - this.metrics = event.metrics - this.context = event.context - this.spanId = event.spanId - this.spanParents = event.spanParents - this.rootSpanId = event.rootSpanId - this.spanAttributes = event.spanAttributes - additionalProperties(event.additionalProperties) - } - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust - * will generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust - * will generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: String) = - datasetRecordId(JsonField.of(datasetRecordId)) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } - - /** - * The 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) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** The timestamp the experiment event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Unique identifier for the experiment */ - fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) - - /** Unique identifier for the experiment */ - @JsonProperty("experiment_id") - @ExcludeMissing - fun experimentId(experimentId: JsonField) = apply { - this.experimentId = experimentId - } - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test cases are - * the same between experiments, so they should not contain experiment-specific state. A - * simple rule of thumb is that if you run the same experiment twice, the `input` should - * be identical - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question - */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * your experiments while digging into analyses. However, we may later use these values - * to re-score outputs or fine-tune your models - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare - * experiments - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare - * experiments - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the experiment event. Use "start" and "end" to track the time span over which the - * experiment event was produced - */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the experiment event. Use "start" and "end" to track the time span over which the - * experiment event was produced - */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - /** - * Context is additional information about the code that produced the experiment event. - * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes - * to track the location in code which produced the experiment event - */ - fun context(context: Context) = context(JsonField.of(context)) - - /** - * Context is additional information about the code that produced the experiment event. - * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes - * to track the location in code which produced the experiment event - */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** - * 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 - */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } - - /** - * An array of the parent `span_ids` of this experiment event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans - */ - fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) - - /** - * An array of the parent `span_ids` of this experiment event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans - */ - @JsonProperty("span_parents") - @ExcludeMissing - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents - } - - /** The `span_id` of the root of the trace this experiment event belongs to */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - - /** The `span_id` of the root of the trace this experiment event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Event = - Event( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanId, - spanParents.map { it.toUnmodifiable() }, - rootSpanId, - spanAttributes, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event - */ - @JsonDeserialize(builder = Context.Builder::class) - @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The function in code which created the experiment event */ - fun callerFunctionname(): String? = - callerFunctionname.getNullable("caller_functionname") - - /** Name of the file in code where the experiment event was created */ - fun callerFilename(): String? = callerFilename.getNullable("caller_filename") - - /** Line of code where the experiment event was created */ - fun callerLineno(): Long? = callerLineno.getNullable("caller_lineno") - - /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename - - /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var callerFunctionname: JsonField = JsonMissing.of() - private var callerFilename: JsonField = JsonMissing.of() - private var callerLineno: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) - } - - /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) - - /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } - - /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } - - /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) - - /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - fun start(): Double? = start.getNullable("start") - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - fun end(): Double? = end.getNullable("end") - - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ - fun promptTokens(): Long? = promptTokens.getNullable("prompt_tokens") - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - fun completionTokens(): Long? = completionTokens.getNullable("completion_tokens") - - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(): Long? = tokens.getNullable("tokens") - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - @JsonProperty("end") @ExcludeMissing fun _end() = end - - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens - - /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var start: JsonField = JsonMissing.of() - private var end: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var tokens: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - additionalProperties(metrics.additionalProperties) - } - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - fun start(start: Double) = start(JsonField.of(start)) - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - fun end(end: Double) = end(JsonField.of(end)) - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - @JsonProperty("end") - @ExcludeMissing - fun end(end: JsonField) = apply { this.end = end } - - /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) - */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - - /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the span, for display purposes only */ - fun name(): String? = name.getNullable("name") - - /** Type of the span, for display purposes only */ - fun type(): Type? = type.getNullable("type") - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val LLM = Type(JsonField.of("llm")) - - val SCORE = Type(JsonField.of("score")) - - val FUNCTION = Type(JsonField.of("function")) - - val EVAL = Type(JsonField.of("eval")) - - val TASK = Type(JsonField.of("task")) - - val TOOL = Type(JsonField.of("tool")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchResponse.kt deleted file mode 100755 index 6a3a69ca..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentFetchResponse.kt +++ /dev/null @@ -1,1601 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects - -@JsonDeserialize(builder = ExperimentFetchResponse.Builder::class) -@NoAutoDetect -class ExperimentFetchResponse -private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of fetched events */ - fun events(): List = events.getRequired("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. - */ - fun cursor(): String? = cursor.getNullable("cursor") - - /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = 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. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ExperimentFetchResponse = apply { - if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentFetchResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ExperimentFetchResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var events: JsonField> = JsonMissing.of() - private var cursor: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(experimentFetchResponse: ExperimentFetchResponse) = apply { - this.events = experimentFetchResponse.events - this.cursor = experimentFetchResponse.cursor - additionalProperties(experimentFetchResponse.additionalProperties) - } - - /** A list of fetched events */ - fun events(events: List) = events(JsonField.of(events)) - - /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } - - /** - * Pagination cursor - * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. - */ - fun cursor(cursor: String) = cursor(JsonField.of(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. - */ - @JsonProperty("cursor") - @ExcludeMissing - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ExperimentFetchResponse = - ExperimentFetchResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Event.Builder::class) - @NoAutoDetect - class Event - private constructor( - private val id: JsonField, - private val datasetRecordId: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val projectId: JsonField, - private val experimentId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you - */ - fun id(): String = id.getRequired("id") - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(): String? = datasetRecordId.getNullable("dataset_record_id") - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the experiment (see the `version` parameter) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** The timestamp the experiment event was created */ - fun created(): OffsetDateTime = created.getRequired("created") - - /** Unique identifier for the project that the experiment belongs under */ - fun projectId(): String = projectId.getRequired("project_id") - - /** Unique identifier for the experiment */ - fun experimentId(): String = experimentId.getRequired("experiment_id") - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models - */ - fun expected(): JsonValue = expected - - /** - * 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.getNullable("scores") - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** A list of tags to log */ - fun tags(): List? = tags.getNullable("tags") - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - fun metrics(): Metrics? = metrics.getNullable("metrics") - - /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event - */ - fun context(): Context? = context.getNullable("context") - - /** - * 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") - - /** - * 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(): List? = spanParents.getNullable("span_parents") - - /** The `span_id` of the root of the trace this experiment event belongs to */ - fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): SpanAttributes? = spanAttributes.getNullable("span_attributes") - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the experiment (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** Unique identifier for the experiment */ - @JsonProperty("experiment_id") @ExcludeMissing fun _experimentId() = experimentId - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same - * between experiments, so they should not contain experiment-specific state. A simple rule - * of thumb is that if you run the same experiment twice, the `input` should be identical - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** - * 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() = spanId - - /** - * An array of the parent `span_ids` of this experiment event. This should be empty for the - * root span of a trace, and should most often contain just one parent element for subspans - */ - @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents - - /** The `span_id` of the root of the trace this experiment event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Event = apply { - if (!validated) { - id() - datasetRecordId() - _xactId() - created() - projectId() - experimentId() - input() - output() - expected() - scores()?.validate() - metadata()?.validate() - tags() - metrics()?.validate() - context()?.validate() - spanId() - spanParents() - rootSpanId() - spanAttributes()?.validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this._xactId == other._xactId && - this.created == other.created && - this.projectId == other.projectId && - this.experimentId == other.experimentId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Event{id=$id, datasetRecordId=$datasetRecordId, _xactId=$_xactId, created=$created, projectId=$projectId, experimentId=$experimentId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var datasetRecordId: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var experimentId: JsonField = JsonMissing.of() - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() - private var spanParents: JsonField> = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(event: Event) = apply { - this.id = event.id - this.datasetRecordId = event.datasetRecordId - this._xactId = event._xactId - this.created = event.created - this.projectId = event.projectId - this.experimentId = event.experimentId - this.input = event.input - this.output = event.output - this.expected = event.expected - this.scores = event.scores - this.metadata = event.metadata - this.tags = event.tags - this.metrics = event.metrics - this.context = event.context - this.spanId = event.spanId - this.spanParents = event.spanParents - this.rootSpanId = event.rootSpanId - this.spanAttributes = event.spanAttributes - additionalProperties(event.additionalProperties) - } - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust - * will generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust - * will generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - fun datasetRecordId(datasetRecordId: String) = - datasetRecordId(JsonField.of(datasetRecordId)) - - /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to - */ - @JsonProperty("dataset_record_id") - @ExcludeMissing - fun datasetRecordId(datasetRecordId: JsonField) = apply { - this.datasetRecordId = datasetRecordId - } - - /** - * The 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) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** The timestamp the experiment event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the experiment event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** Unique identifier for the project that the experiment belongs under */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project that the experiment belongs under */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Unique identifier for the experiment */ - fun experimentId(experimentId: String) = experimentId(JsonField.of(experimentId)) - - /** Unique identifier for the experiment */ - @JsonProperty("experiment_id") - @ExcludeMissing - fun experimentId(experimentId: JsonField) = apply { - this.experimentId = experimentId - } - - /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable - * object). Later on, Braintrust will use the `input` to know whether two test cases are - * the same between experiments, so they should not contain experiment-specific state. A - * simple rule of thumb is that if you run the same experiment twice, the `input` should - * be identical - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question - */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * your experiments while digging into analyses. However, we may later use these values - * to re-score outputs or fine-tune your models - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare - * experiments - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare - * experiments - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the experiment event. Use "start" and "end" to track the time span over which the - * experiment event was produced - */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the experiment event. Use "start" and "end" to track the time span over which the - * experiment event was produced - */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - /** - * Context is additional information about the code that produced the experiment event. - * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes - * to track the location in code which produced the experiment event - */ - fun context(context: Context) = context(JsonField.of(context)) - - /** - * Context is additional information about the code that produced the experiment event. - * It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes - * to track the location in code which produced the experiment event - */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** - * 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 - */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } - - /** - * An array of the parent `span_ids` of this experiment event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans - */ - fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) - - /** - * An array of the parent `span_ids` of this experiment event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans - */ - @JsonProperty("span_parents") - @ExcludeMissing - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents - } - - /** The `span_id` of the root of the trace this experiment event belongs to */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - - /** The `span_id` of the root of the trace this experiment event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Event = - Event( - id, - datasetRecordId, - _xactId, - created, - projectId, - experimentId, - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanId, - spanParents.map { it.toUnmodifiable() }, - rootSpanId, - spanAttributes, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event - */ - @JsonDeserialize(builder = Context.Builder::class) - @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The function in code which created the experiment event */ - fun callerFunctionname(): String? = - callerFunctionname.getNullable("caller_functionname") - - /** Name of the file in code where the experiment event was created */ - fun callerFilename(): String? = callerFilename.getNullable("caller_filename") - - /** Line of code where the experiment event was created */ - fun callerLineno(): Long? = callerLineno.getNullable("caller_lineno") - - /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename - - /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var callerFunctionname: JsonField = JsonMissing.of() - private var callerFilename: JsonField = JsonMissing.of() - private var callerLineno: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) - } - - /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) - - /** The function in code which created the experiment event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } - - /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) - - /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } - - /** Line of code where the experiment event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) - - /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced - */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - fun start(): Double? = start.getNullable("start") - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - fun end(): Double? = end.getNullable("end") - - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ - fun promptTokens(): Long? = promptTokens.getNullable("prompt_tokens") - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - fun completionTokens(): Long? = completionTokens.getNullable("completion_tokens") - - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(): Long? = tokens.getNullable("tokens") - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - @JsonProperty("end") @ExcludeMissing fun _end() = end - - /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) - */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens - - /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var start: JsonField = JsonMissing.of() - private var end: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var tokens: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - additionalProperties(metrics.additionalProperties) - } - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - fun start(start: Double) = start(JsonField.of(start)) - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event started - */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - fun end(end: Double) = end(JsonField.of(end)) - - /** - * A unix timestamp recording when the section of code which produced the experiment - * event finished - */ - @JsonProperty("end") - @ExcludeMissing - fun end(end: JsonField) = apply { this.end = end } - - /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) - */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * The number of tokens in the prompt used to generate the experiment event (only - * set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - /** The total number of tokens in the input and output of the experiment event. */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - - /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the span, for display purposes only */ - fun name(): String? = name.getNullable("name") - - /** Type of the span, for display purposes only */ - fun type(): Type? = type.getNullable("type") - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val LLM = Type(JsonField.of("llm")) - - val SCORE = Type(JsonField.of("score")) - - val FUNCTION = Type(JsonField.of("function")) - - val EVAL = Type(JsonField.of("eval")) - - val TASK = Type(JsonField.of("task")) - - val TOOL = Type(JsonField.of("tool")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt index d5e9a839..8bde22ea 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertParams.kt @@ -2,34 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ExperimentInsertParams constructor( + private val experimentId: String, + private val events: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ExperimentInsertParams -constructor( - private val experimentId: String, - private val events: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @@ -37,7 +50,7 @@ constructor( fun events(): List = events internal fun getBody(): ExperimentInsertBody { - return ExperimentInsertBody(events, additionalBodyProperties) + return ExperimentInsertBody(events, additionalBodyProperties) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -45,24 +58,21 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @JsonDeserialize(builder = ExperimentInsertBody.Builder::class) @NoAutoDetect - class ExperimentInsertBody - internal constructor( - private val events: List?, - private val additionalProperties: Map, - ) { + class ExperimentInsertBody internal constructor(private val events: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of experiment events to insert */ - @JsonProperty("events") fun events(): List? = events + @JsonProperty("events") + fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -71,24 +81,23 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ExperimentInsertBody && - this.events == other.events && - this.additionalProperties == other.additionalProperties + return other is ExperimentInsertBody && + this.events == other.events && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(events, additionalProperties) + } + return hashCode } - override fun toString() = - "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" + override fun toString() = "ExperimentInsertBody{events=$events, additionalProperties=$additionalProperties}" companion object { @@ -106,7 +115,10 @@ constructor( } /** A list of experiment events to insert */ - @JsonProperty("events") fun events(events: List) = apply { this.events = events } + @JsonProperty("events") + fun events(events: List) = apply { + this.events = events + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -122,12 +134,9 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentInsertBody = - ExperimentInsertBody( - checkNotNull(events) { "`events` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() - ) + fun build(): ExperimentInsertBody = ExperimentInsertBody(checkNotNull(events) { + "`events` is required but was not set" + }.toUnmodifiable(), additionalProperties.toUnmodifiable()) } } @@ -138,30 +147,29 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentInsertParams && - this.experimentId == other.experimentId && - this.events == other.events && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentInsertParams && + this.experimentId == other.experimentId && + this.events == other.events && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - events, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + events, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ExperimentInsertParams{experimentId=$experimentId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ExperimentInsertParams{experimentId=$experimentId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -188,7 +196,9 @@ constructor( } /** 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 { @@ -197,7 +207,9 @@ constructor( } /** A list of experiment events to insert */ - fun addEvent(event: Event) = apply { this.events.add(event) } + fun addEvent(event: Event) = apply { + this.events.add(event) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -237,7 +249,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -248,155 +262,124 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentInsertParams = - ExperimentInsertParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - checkNotNull(events) { "`events` is required but was not set" }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentInsertParams = ExperimentInsertParams( + checkNotNull(experimentId) { + "`experimentId` is required but was not set" + }, + checkNotNull(events) { + "`events` is required but was not set" + }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Event.Deserializer::class) @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertExperimentEventReplace: InsertExperimentEventReplace? = null, - private val insertExperimentEventMerge: InsertExperimentEventMerge? = null, - private val _json: JsonValue? = null, - ) { + class Event private constructor(private val insertExperimentEventReplace: InsertExperimentEventReplace? = null, private val insertExperimentEventMerge: InsertExperimentEventMerge? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun insertExperimentEventReplace(): InsertExperimentEventReplace? = - insertExperimentEventReplace - + fun insertExperimentEventReplace(): InsertExperimentEventReplace? = insertExperimentEventReplace fun insertExperimentEventMerge(): InsertExperimentEventMerge? = insertExperimentEventMerge fun isInsertExperimentEventReplace(): Boolean = insertExperimentEventReplace != null - fun isInsertExperimentEventMerge(): Boolean = insertExperimentEventMerge != null - fun asInsertExperimentEventReplace(): InsertExperimentEventReplace = - insertExperimentEventReplace.getOrThrow("insertExperimentEventReplace") - - fun asInsertExperimentEventMerge(): InsertExperimentEventMerge = - insertExperimentEventMerge.getOrThrow("insertExperimentEventMerge") + fun asInsertExperimentEventReplace(): InsertExperimentEventReplace = insertExperimentEventReplace.getOrThrow("insertExperimentEventReplace") + fun asInsertExperimentEventMerge(): InsertExperimentEventMerge = insertExperimentEventMerge.getOrThrow("insertExperimentEventMerge") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - insertExperimentEventReplace != null -> - visitor.visitInsertExperimentEventReplace(insertExperimentEventReplace) - insertExperimentEventMerge != null -> - visitor.visitInsertExperimentEventMerge(insertExperimentEventMerge) - else -> visitor.unknown(_json) - } + return when { + insertExperimentEventReplace != null -> visitor.visitInsertExperimentEventReplace(insertExperimentEventReplace) + insertExperimentEventMerge != null -> visitor.visitInsertExperimentEventMerge(insertExperimentEventMerge) + else -> visitor.unknown(_json) + } } fun validate(): Event = apply { if (!validated) { - if (insertExperimentEventReplace == null && insertExperimentEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertExperimentEventReplace?.validate() - insertExperimentEventMerge?.validate() - validated = true + if (insertExperimentEventReplace == null && insertExperimentEventMerge == null) { + throw BraintrustInvalidDataException("Unknown Event: $_json") + } + insertExperimentEventReplace?.validate() + insertExperimentEventMerge?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Event && - this.insertExperimentEventReplace == other.insertExperimentEventReplace && - this.insertExperimentEventMerge == other.insertExperimentEventMerge + return other is Event && + this.insertExperimentEventReplace == other.insertExperimentEventReplace && + this.insertExperimentEventMerge == other.insertExperimentEventMerge } override fun hashCode(): Int { - return Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) + return Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) } override fun toString(): String { - return when { - insertExperimentEventReplace != null -> - "Event{insertExperimentEventReplace=$insertExperimentEventReplace}" - insertExperimentEventMerge != null -> - "Event{insertExperimentEventMerge=$insertExperimentEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } + return when { + insertExperimentEventReplace != null -> "Event{insertExperimentEventReplace=$insertExperimentEventReplace}" + insertExperimentEventMerge != null -> "Event{insertExperimentEventMerge=$insertExperimentEventMerge}" + _json != null -> "Event{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Event") + } } companion object { - fun ofInsertExperimentEventReplace( - insertExperimentEventReplace: InsertExperimentEventReplace - ) = Event(insertExperimentEventReplace = insertExperimentEventReplace) + fun ofInsertExperimentEventReplace(insertExperimentEventReplace: InsertExperimentEventReplace) = Event(insertExperimentEventReplace = insertExperimentEventReplace) - fun ofInsertExperimentEventMerge( - insertExperimentEventMerge: InsertExperimentEventMerge - ) = Event(insertExperimentEventMerge = insertExperimentEventMerge) + fun ofInsertExperimentEventMerge(insertExperimentEventMerge: InsertExperimentEventMerge) = Event(insertExperimentEventMerge = insertExperimentEventMerge) } interface Visitor { - fun visitInsertExperimentEventReplace( - insertExperimentEventReplace: InsertExperimentEventReplace - ): T + fun visitInsertExperimentEventReplace(insertExperimentEventReplace: InsertExperimentEventReplace): T - fun visitInsertExperimentEventMerge( - insertExperimentEventMerge: InsertExperimentEventMerge - ): T + fun visitInsertExperimentEventMerge(insertExperimentEventMerge: InsertExperimentEventMerge): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") + throw BraintrustInvalidDataException("Unknown Event: $json") } } class Deserializer : BaseDeserializer(Event::class) { override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertExperimentEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertExperimentEventMerge = it, _json = json) - } - - return Event(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Event(insertExperimentEventReplace = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Event(insertExperimentEventMerge = it, _json = json) + } + + return Event(_json = json) } } class Serializer : BaseSerializer(Event::class) { - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertExperimentEventReplace != null -> - generator.writeObject(value.insertExperimentEventReplace) - value.insertExperimentEventMerge != null -> - generator.writeObject(value.insertExperimentEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } + override fun serialize(value: Event, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.insertExperimentEventReplace != null -> generator.writeObject(value.insertExperimentEventReplace) + value.insertExperimentEventMerge != null -> generator.writeObject(value.insertExperimentEventMerge) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Event") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt deleted file mode 100755 index 857272e8..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentInsertResponse.kt +++ /dev/null @@ -1,121 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = ExperimentInsertResponse.Builder::class) -@NoAutoDetect -class ExperimentInsertResponse -private constructor( - private val rowIds: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - 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 - */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ExperimentInsertResponse = apply { - if (!validated) { - rowIds() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentInsertResponse && - this.rowIds == other.rowIds && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(rowIds, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ExperimentInsertResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var rowIds: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(experimentInsertResponse: ExperimentInsertResponse) = apply { - this.rowIds = experimentInsertResponse.rowIds - additionalProperties(experimentInsertResponse.additionalProperties) - } - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - @JsonProperty("row_ids") - @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ExperimentInsertResponse = - ExperimentInsertResponse( - rowIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt index 47a8ae4e..91fe41e3 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPage.kt @@ -2,101 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.services.blocking.ExperimentService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class ExperimentListPage -private constructor( - private val experimentService: ExperimentService, - private val params: ExperimentListParams, - private val response: Response, -) { +class ExperimentListPage private constructor(private val experimentService: ExperimentService, private val params: ExperimentListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentListPage && - this.experimentService == other.experimentService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ExperimentListPage && + this.experimentService == other.experimentService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - experimentService, - params, - response, - ) + return Objects.hash( + experimentService, + params, + response, + ) } - override fun toString() = - "ExperimentListPage{experimentService=$experimentService, params=$params, response=$response}" + override fun toString() = "ExperimentListPage{experimentService=$experimentService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ExperimentListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): ExperimentListPage? { - return getNextPageParams()?.let { experimentService.list(it) } + return getNextPageParams()?.let { + experimentService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - experimentService: ExperimentService, - params: ExperimentListParams, - response: Response - ) = - ExperimentListPage( - experimentService, - params, - response, - ) + fun of(experimentService: ExperimentService, params: ExperimentListParams, response: Response) = ExperimentListPage( + experimentService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -104,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ExperimentListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ExperimentListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -157,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ExperimentListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: ExperimentListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt index d74952fb..cd24244d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListPageAsync.kt @@ -2,103 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.ExperimentServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Experiment +import com.braintrustdata.api.services.async.ExperimentServiceAsync -class ExperimentListPageAsync -private constructor( - private val experimentService: ExperimentServiceAsync, - private val params: ExperimentListParams, - private val response: Response, -) { +class ExperimentListPageAsync private constructor(private val experimentService: ExperimentServiceAsync, private val params: ExperimentListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentListPageAsync && - this.experimentService == other.experimentService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ExperimentListPageAsync && + this.experimentService == other.experimentService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - experimentService, - params, - response, - ) + return Objects.hash( + experimentService, + params, + response, + ) } - override fun toString() = - "ExperimentListPageAsync{experimentService=$experimentService, params=$params, response=$response}" + override fun toString() = "ExperimentListPageAsync{experimentService=$experimentService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ExperimentListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ExperimentListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ExperimentListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): ExperimentListPageAsync? { - return getNextPageParams()?.let { experimentService.list(it) } + return getNextPageParams()?.let { + experimentService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - experimentService: ExperimentServiceAsync, - params: ExperimentListParams, - response: Response - ) = - ExperimentListPageAsync( - experimentService, - params, - response, - ) + fun of(experimentService: ExperimentServiceAsync, params: ExperimentListParams, response: Response) = ExperimentListPageAsync( + experimentService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -106,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ExperimentListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ExperimentListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -159,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ExperimentListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: ExperimentListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt index 5817844c..043525f2 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentListParams.kt @@ -2,35 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ExperimentListParams constructor( + private val endingBefore: String?, + private val experimentName: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectId: String?, + private val projectName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class ExperimentListParams -constructor( - private val endingBefore: String?, - private val experimentName: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectId: String?, - private val projectName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun endingBefore(): String? = endingBefore @@ -50,17 +67,33 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.experimentName?.let { params.put("experiment_name", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.experimentName?.let { + params.put("experiment_name", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.projectId?.let { + params.put("project_id", listOf(it.toString())) + } + this.projectName?.let { + params.put("project_name", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -70,40 +103,39 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentListParams && - this.endingBefore == other.endingBefore && - this.experimentName == other.experimentName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ExperimentListParams && + this.endingBefore == other.endingBefore && + this.experimentName == other.experimentName && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectId == other.projectId && + this.projectName == other.projectName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - experimentName, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + endingBefore, + experimentName, + ids, + limit, + orgName, + projectId, + projectName, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ExperimentListParams{endingBefore=$endingBefore, experimentName=$experimentName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -142,53 +174,73 @@ 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 + } /** Name of the experiment to search for */ - fun experimentName(experimentName: String) = apply { this.experimentName = experimentName } + fun experimentName(experimentName: String) = apply { + this.experimentName = 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(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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: String) = apply { + this.projectName = projectName + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -228,84 +280,79 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): ExperimentListParams = - ExperimentListParams( - endingBefore, - experimentName, - ids, - limit, - orgName, - projectId, - projectName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): ExperimentListParams = ExperimentListParams( + endingBefore, + experimentName, + ids, + limit, + orgName, + projectId, + projectName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -322,38 +369,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt index 77220735..f28734e9 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ExperimentRetrieveParams -constructor( - private val experimentId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class ExperimentRetrieveParams constructor(private val experimentId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun experimentId(): String = experimentId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentRetrieveParams && - this.experimentId == other.experimentId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ExperimentRetrieveParams && + this.experimentId == other.experimentId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - experimentId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + experimentId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ExperimentRetrieveParams{experimentId=$experimentId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ExperimentRetrieveParams{experimentId=$experimentId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** Experiment id */ - fun experimentId(experimentId: String) = apply { this.experimentId = experimentId } + fun experimentId(experimentId: String) = apply { + this.experimentId = experimentId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): ExperimentRetrieveParams = - ExperimentRetrieveParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): ExperimentRetrieveParams = ExperimentRetrieveParams( + checkNotNull(experimentId) { + "`experimentId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt index 7c299139..a39e8b47 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParams.kt @@ -2,18 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ExperimentSummarizeParams -constructor( - private val experimentId: String, - private val comparisonExperimentId: String?, - private val summarizeScores: Boolean?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, +class ExperimentSummarizeParams constructor( + private val experimentId: String, + private val comparisonExperimentId: String?, + private val summarizeScores: Boolean?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + ) { fun experimentId(): String = experimentId @@ -23,22 +52,24 @@ constructor( fun summarizeScores(): Boolean? = summarizeScores internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.comparisonExperimentId?.let { - params.put("comparison_experiment_id", listOf(it.toString())) - } - this.summarizeScores?.let { params.put("summarize_scores", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.comparisonExperimentId?.let { + params.put("comparison_experiment_id", listOf(it.toString())) + } + this.summarizeScores?.let { + params.put("summarize_scores", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -46,30 +77,29 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentSummarizeParams && - this.experimentId == other.experimentId && - this.comparisonExperimentId == other.comparisonExperimentId && - this.summarizeScores == other.summarizeScores && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ExperimentSummarizeParams && + this.experimentId == other.experimentId && + this.comparisonExperimentId == other.comparisonExperimentId && + this.summarizeScores == other.summarizeScores && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - experimentId, - comparisonExperimentId, - summarizeScores, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + experimentId, + comparisonExperimentId, + summarizeScores, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ExperimentSummarizeParams{experimentId=$experimentId, comparisonExperimentId=$comparisonExperimentId, summarizeScores=$summarizeScores, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -96,21 +126,23 @@ constructor( } /** 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 } /** - * 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 @@ -154,15 +186,18 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): ExperimentSummarizeParams = - ExperimentSummarizeParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - comparisonExperimentId, - summarizeScores, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): ExperimentSummarizeParams = ExperimentSummarizeParams( + checkNotNull(experimentId) { + "`experimentId` is required but was not set" + }, + comparisonExperimentId, + summarizeScores, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponse.kt deleted file mode 100755 index 90257efd..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponse.kt +++ /dev/null @@ -1,396 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -/** Summary of an experiment */ -@JsonDeserialize(builder = ExperimentSummarizeResponse.Builder::class) -@NoAutoDetect -class ExperimentSummarizeResponse -private constructor( - private val projectName: JsonField, - private val experimentName: JsonField, - private val projectUrl: JsonField, - private val experimentUrl: JsonField, - private val comparisonExperimentName: JsonField, - private val scores: JsonField, - private val metrics: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the project that the experiment belongs to */ - fun projectName(): String = projectName.getRequired("project_name") - - /** Name of the experiment */ - fun experimentName(): String = experimentName.getRequired("experiment_name") - - /** URL to the project's page in the Braintrust app */ - fun projectUrl(): String = projectUrl.getRequired("project_url") - - /** URL to the experiment's page in the Braintrust app */ - fun experimentUrl(): String = experimentUrl.getRequired("experiment_url") - - /** The experiment which scores are baselined against */ - fun comparisonExperimentName(): String? = - comparisonExperimentName.getNullable("comparison_experiment_name") - - /** Summary of the experiment's scores */ - fun scores(): Scores? = scores.getNullable("scores") - - /** Summary of the experiment's metrics */ - fun metrics(): Metrics? = metrics.getNullable("metrics") - - /** Name of the project that the experiment belongs to */ - @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName - - /** Name of the experiment */ - @JsonProperty("experiment_name") @ExcludeMissing fun _experimentName() = experimentName - - /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") @ExcludeMissing fun _projectUrl() = projectUrl - - /** URL to the experiment's page in the Braintrust app */ - @JsonProperty("experiment_url") @ExcludeMissing fun _experimentUrl() = experimentUrl - - /** The experiment which scores are baselined against */ - @JsonProperty("comparison_experiment_name") - @ExcludeMissing - fun _comparisonExperimentName() = comparisonExperimentName - - /** Summary of the experiment's scores */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** Summary of the experiment's metrics */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ExperimentSummarizeResponse = apply { - if (!validated) { - projectName() - experimentName() - projectUrl() - experimentUrl() - comparisonExperimentName() - scores()?.validate() - metrics()?.validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentSummarizeResponse && - this.projectName == other.projectName && - this.experimentName == other.experimentName && - this.projectUrl == other.projectUrl && - this.experimentUrl == other.experimentUrl && - this.comparisonExperimentName == other.comparisonExperimentName && - this.scores == other.scores && - this.metrics == other.metrics && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectName, - experimentName, - projectUrl, - experimentUrl, - comparisonExperimentName, - scores, - metrics, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ExperimentSummarizeResponse{projectName=$projectName, experimentName=$experimentName, projectUrl=$projectUrl, experimentUrl=$experimentUrl, comparisonExperimentName=$comparisonExperimentName, scores=$scores, metrics=$metrics, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var projectName: JsonField = JsonMissing.of() - private var experimentName: JsonField = JsonMissing.of() - private var projectUrl: JsonField = JsonMissing.of() - private var experimentUrl: JsonField = JsonMissing.of() - private var comparisonExperimentName: JsonField = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(experimentSummarizeResponse: ExperimentSummarizeResponse) = apply { - this.projectName = experimentSummarizeResponse.projectName - this.experimentName = experimentSummarizeResponse.experimentName - this.projectUrl = experimentSummarizeResponse.projectUrl - this.experimentUrl = experimentSummarizeResponse.experimentUrl - this.comparisonExperimentName = experimentSummarizeResponse.comparisonExperimentName - this.scores = experimentSummarizeResponse.scores - this.metrics = experimentSummarizeResponse.metrics - additionalProperties(experimentSummarizeResponse.additionalProperties) - } - - /** Name of the project that the experiment belongs to */ - fun projectName(projectName: String) = projectName(JsonField.of(projectName)) - - /** Name of the project that the experiment belongs to */ - @JsonProperty("project_name") - @ExcludeMissing - fun projectName(projectName: JsonField) = apply { this.projectName = projectName } - - /** Name of the experiment */ - fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) - - /** Name of the experiment */ - @JsonProperty("experiment_name") - @ExcludeMissing - fun experimentName(experimentName: JsonField) = apply { - this.experimentName = experimentName - } - - /** URL to the project's page in the Braintrust app */ - fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) - - /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") - @ExcludeMissing - fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } - - /** URL to the experiment's page in the Braintrust app */ - fun experimentUrl(experimentUrl: String) = experimentUrl(JsonField.of(experimentUrl)) - - /** URL to the experiment's page in the Braintrust app */ - @JsonProperty("experiment_url") - @ExcludeMissing - fun experimentUrl(experimentUrl: JsonField) = apply { - this.experimentUrl = experimentUrl - } - - /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: String) = - comparisonExperimentName(JsonField.of(comparisonExperimentName)) - - /** The experiment which scores are baselined against */ - @JsonProperty("comparison_experiment_name") - @ExcludeMissing - fun comparisonExperimentName(comparisonExperimentName: JsonField) = apply { - this.comparisonExperimentName = comparisonExperimentName - } - - /** Summary of the experiment's scores */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** Summary of the experiment's scores */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** Summary of the experiment's metrics */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** Summary of the experiment's metrics */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ExperimentSummarizeResponse = - ExperimentSummarizeResponse( - projectName, - experimentName, - projectUrl, - experimentUrl, - comparisonExperimentName, - scores, - metrics, - additionalProperties.toUnmodifiable(), - ) - } - - /** Summary of the experiment's metrics */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metrics{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metrics: Metrics) = apply { - additionalProperties(metrics.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = Metrics(additionalProperties.toUnmodifiable()) - } - } - - /** Summary of the experiment's scores */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt index 96ff5d88..78136c11 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ExperimentUpdateParams.kt @@ -2,31 +2,54 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ExperimentUpdateParams constructor( + private val experimentId: String, + private val baseExpId: String?, + private val datasetId: String?, + private val datasetVersion: String?, + private val description: String?, + private val metadata: Metadata?, + private val name: String?, + private val public_: Boolean?, + private val repoInfo: RepoInfo?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ExperimentUpdateParams -constructor( - private val experimentId: String, - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun experimentId(): String = experimentId @@ -48,17 +71,17 @@ constructor( fun repoInfo(): RepoInfo? = repoInfo internal fun getBody(): ExperimentUpdateBody { - return ExperimentUpdateBody( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalBodyProperties, - ) + return ExperimentUpdateBody( + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -66,60 +89,69 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> experimentId - else -> "" - } + return when (index) { + 0 -> experimentId + else -> "" + } } @JsonDeserialize(builder = ExperimentUpdateBody.Builder::class) @NoAutoDetect - class ExperimentUpdateBody - internal constructor( - private val baseExpId: String?, - private val datasetId: String?, - private val datasetVersion: String?, - private val description: String?, - private val metadata: Metadata?, - private val name: String?, - private val public_: Boolean?, - private val repoInfo: RepoInfo?, - private val additionalProperties: Map, + class ExperimentUpdateBody internal constructor( + private val baseExpId: String?, + private val datasetId: String?, + private val datasetVersion: String?, + private val description: String?, + private val metadata: Metadata?, + private val name: String?, + private val public_: Boolean?, + private val repoInfo: RepoInfo?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") fun baseExpId(): String? = baseExpId + @JsonProperty("base_exp_id") + fun baseExpId(): String? = 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") fun datasetId(): String? = datasetId + @JsonProperty("dataset_id") + fun datasetId(): String? = 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") fun datasetVersion(): String? = datasetVersion + @JsonProperty("dataset_version") + fun datasetVersion(): String? = datasetVersion /** Textual description of the experiment */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + @JsonProperty("metadata") + fun metadata(): Metadata? = metadata /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = 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") fun public_(): Boolean? = public_ + @JsonProperty("public") + fun public_(): Boolean? = public_ /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") fun repoInfo(): RepoInfo? = repoInfo + @JsonProperty("repo_info") + fun repoInfo(): RepoInfo? = repoInfo @JsonAnyGetter @ExcludeMissing @@ -128,42 +160,40 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentUpdateBody && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ExperimentUpdateBody && + this.baseExpId == other.baseExpId && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.description == other.description && + this.metadata == other.metadata && + this.name == other.name && + this.public_ == other.public_ && + this.repoInfo == other.repoInfo && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" + override fun toString() = "ExperimentUpdateBody{baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalProperties=$additionalProperties}" companion object { @@ -196,18 +226,22 @@ constructor( /** Id of default base experiment to compare against when viewing this experiment */ @JsonProperty("base_exp_id") - fun baseExpId(baseExpId: String) = apply { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: String) = apply { + this.baseExpId = baseExpId + } /** * Identifier of the linked dataset, or null if the experiment is not linked to a * dataset */ @JsonProperty("dataset_id") - fun datasetId(datasetId: String) = apply { this.datasetId = datasetId } + fun datasetId(datasetId: String) = 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. */ @JsonProperty("dataset_version") fun datasetVersion(datasetVersion: String) = apply { @@ -216,24 +250,36 @@ constructor( /** Textual description of the experiment */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** User-controlled metadata about the experiment */ @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = apply { + this.metadata = metadata + } /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = 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 */ - @JsonProperty("public") fun public_(public_: Boolean) = apply { this.public_ = public_ } + @JsonProperty("public") + fun public_(public_: Boolean) = apply { + this.public_ = public_ + } /** Metadata about the state of the repo when the experiment was created */ @JsonProperty("repo_info") - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: RepoInfo) = apply { + this.repoInfo = repoInfo + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -249,18 +295,17 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ExperimentUpdateBody = - ExperimentUpdateBody( - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalProperties.toUnmodifiable(), - ) + fun build(): ExperimentUpdateBody = ExperimentUpdateBody( + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalProperties.toUnmodifiable(), + ) } } @@ -271,44 +316,43 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExperimentUpdateParams && - this.experimentId == other.experimentId && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.description == other.description && - this.metadata == other.metadata && - this.name == other.name && - this.public_ == other.public_ && - this.repoInfo == other.repoInfo && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ExperimentUpdateParams && + this.experimentId == other.experimentId && + this.baseExpId == other.baseExpId && + this.datasetId == other.datasetId && + this.datasetVersion == other.datasetVersion && + this.description == other.description && + this.metadata == other.metadata && + this.name == other.name && + this.public_ == other.public_ && + this.repoInfo == other.repoInfo && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - experimentId, - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + experimentId, + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ExperimentUpdateParams{experimentId=$experimentId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ExperimentUpdateParams{experimentId=$experimentId, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, description=$description, metadata=$metadata, name=$name, public_=$public_, repoInfo=$repoInfo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -349,39 +393,58 @@ constructor( } /** 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 { this.baseExpId = baseExpId } + fun baseExpId(baseExpId: String) = apply { + this.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 { this.datasetId = datasetId } + fun datasetId(datasetId: String) = 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) = apply { this.datasetVersion = datasetVersion } + fun datasetVersion(datasetVersion: String) = apply { + this.datasetVersion = datasetVersion + } /** Textual description of the experiment */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = apply { + this.metadata = metadata + } /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = 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) = apply { this.public_ = public_ } + fun public_(public_: Boolean) = apply { + this.public_ = public_ + } /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = apply { this.repoInfo = repoInfo } + fun repoInfo(repoInfo: RepoInfo) = apply { + this.repoInfo = repoInfo + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -421,7 +484,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -432,35 +497,32 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ExperimentUpdateParams = - ExperimentUpdateParams( - checkNotNull(experimentId) { "`experimentId` is required but was not set" }, - baseExpId, - datasetId, - datasetVersion, - description, - metadata, - name, - public_, - repoInfo, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ExperimentUpdateParams = ExperimentUpdateParams( + checkNotNull(experimentId) { + "`experimentId` is required but was not set" + }, + baseExpId, + datasetId, + datasetVersion, + description, + metadata, + name, + public_, + repoInfo, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** User-controlled metadata about the experiment */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var hashCode: Int = 0 @@ -471,18 +533,19 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequest.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequest.kt deleted file mode 100755 index b1e4f195..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequest.kt +++ /dev/null @@ -1,113 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = FeedbackDatasetEventRequest.Builder::class) -@NoAutoDetect -class FeedbackDatasetEventRequest -private constructor( - private val feedback: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of dataset feedback items */ - fun feedback(): List = feedback.getRequired("feedback") - - /** A list of dataset feedback items */ - @JsonProperty("feedback") @ExcludeMissing fun _feedback() = feedback - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): FeedbackDatasetEventRequest = apply { - if (!validated) { - feedback().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FeedbackDatasetEventRequest && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode - } - - override fun toString() = - "FeedbackDatasetEventRequest{feedback=$feedback, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var feedback: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(feedbackDatasetEventRequest: FeedbackDatasetEventRequest) = apply { - this.feedback = feedbackDatasetEventRequest.feedback - additionalProperties(feedbackDatasetEventRequest.additionalProperties) - } - - /** A list of dataset feedback items */ - fun feedback(feedback: List) = feedback(JsonField.of(feedback)) - - /** A list of dataset feedback items */ - @JsonProperty("feedback") - @ExcludeMissing - fun feedback(feedback: JsonField>) = apply { - this.feedback = feedback - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): FeedbackDatasetEventRequest = - FeedbackDatasetEventRequest( - feedback.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt index c3c8484e..6380c2b5 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackDatasetItem.kt @@ -2,30 +2,46 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = FeedbackDatasetItem.Builder::class) @NoAutoDetect -class FeedbackDatasetItem -private constructor( - private val id: JsonField, - private val comment: JsonField, - private val metadata: JsonField, - private val source: JsonField, - private val additionalProperties: Map, +class FeedbackDatasetItem private constructor( + private val id: JsonField, + private val comment: JsonField, + private val metadata: JsonField, + private val source: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -33,8 +49,8 @@ private constructor( private var hashCode: Int = 0 /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * The id of the dataset event to log feedback for. This is the row `id` returned + * by `POST /v1/dataset/{dataset_id}/insert` */ fun id(): String = id.getRequired("id") @@ -42,8 +58,8 @@ private constructor( fun comment(): String? = 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. + * 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. */ fun metadata(): Metadata? = metadata.getNullable("metadata") @@ -51,22 +67,30 @@ private constructor( fun source(): Source? = source.getNullable("source") /** - * 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() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** An optional comment string to log about the dataset event */ - @JsonProperty("comment") @ExcludeMissing fun _comment() = comment + @JsonProperty("comment") + @ExcludeMissing + fun _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. + * 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. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source() = source + @JsonProperty("source") + @ExcludeMissing + fun _source() = source @JsonAnyGetter @ExcludeMissing @@ -74,45 +98,43 @@ private constructor( fun validate(): FeedbackDatasetItem = apply { if (!validated) { - id() - comment() - metadata()?.validate() - source() - validated = true + id() + comment() + metadata()?.validate() + source() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FeedbackDatasetItem && - this.id == other.id && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FeedbackDatasetItem && + this.id == other.id && + this.comment == other.comment && + this.metadata == other.metadata && + this.source == other.source && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + comment, + metadata, + source, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackDatasetItem{id=$id, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" companion object { @@ -136,16 +158,20 @@ private constructor( } /** - * The id of the dataset event to log feedback for. This is the row `id` returned by `POST - * /v1/dataset/{dataset_id}/insert` + * 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` */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** An optional comment string to log about the dataset event */ fun comment(comment: String) = comment(JsonField.of(comment)) @@ -153,21 +179,25 @@ private constructor( /** An optional comment string to log about the dataset event */ @JsonProperty("comment") @ExcludeMissing - 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. + * 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. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * 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. */ @JsonProperty("metadata") @ExcludeMissing - 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.of(source)) @@ -175,7 +205,9 @@ private constructor( /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing - fun source(source: JsonField) = apply { this.source = source } + fun source(source: JsonField) = apply { + this.source = source + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -191,26 +223,22 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FeedbackDatasetItem = - FeedbackDatasetItem( - id, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) + fun build(): FeedbackDatasetItem = FeedbackDatasetItem( + id, + comment, + metadata, + source, + additionalProperties.toUnmodifiable(), + ) } /** - * 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. + * 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. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -222,25 +250,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" @@ -276,20 +305,18 @@ private constructor( } } - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Source @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Source && this.value == other.value + return other is Source && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -320,21 +347,19 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + APP -> Value.APP + API -> Value.API + EXTERNAL -> Value.EXTERNAL + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } + fun known(): Known = when (this) { + APP -> Known.APP + API -> Known.API + EXTERNAL -> Known.EXTERNAL + else -> throw BraintrustInvalidDataException("Unknown Source: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequest.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequest.kt deleted file mode 100755 index 84ec49c7..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequest.kt +++ /dev/null @@ -1,113 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = FeedbackExperimentEventRequest.Builder::class) -@NoAutoDetect -class FeedbackExperimentEventRequest -private constructor( - private val feedback: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of experiment feedback items */ - fun feedback(): List = feedback.getRequired("feedback") - - /** A list of experiment feedback items */ - @JsonProperty("feedback") @ExcludeMissing fun _feedback() = feedback - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): FeedbackExperimentEventRequest = apply { - if (!validated) { - feedback().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FeedbackExperimentEventRequest && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode - } - - override fun toString() = - "FeedbackExperimentEventRequest{feedback=$feedback, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var feedback: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(feedbackExperimentEventRequest: FeedbackExperimentEventRequest) = apply { - this.feedback = feedbackExperimentEventRequest.feedback - additionalProperties(feedbackExperimentEventRequest.additionalProperties) - } - - /** A list of experiment feedback items */ - fun feedback(feedback: List) = feedback(JsonField.of(feedback)) - - /** A list of experiment feedback items */ - @JsonProperty("feedback") - @ExcludeMissing - fun feedback(feedback: JsonField>) = apply { - this.feedback = feedback - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): FeedbackExperimentEventRequest = - FeedbackExperimentEventRequest( - feedback.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt index 46b51169..d04f4557 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackExperimentItem.kt @@ -2,32 +2,48 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = FeedbackExperimentItem.Builder::class) @NoAutoDetect -class FeedbackExperimentItem -private constructor( - private val id: JsonField, - private val scores: JsonField, - private val expected: JsonValue, - private val comment: JsonField, - private val metadata: JsonField, - private val source: JsonField, - private val additionalProperties: Map, +class FeedbackExperimentItem private constructor( + private val id: JsonField, + private val scores: JsonField, + private val expected: JsonValue, + private val comment: JsonField, + private val metadata: JsonField, + private val source: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -35,20 +51,20 @@ private constructor( private var hashCode: Int = 0 /** - * The id of the experiment event to log feedback for. This is the row `id` returned by `POST - * /v1/experiment/{experiment_id}/insert` + * The id of the experiment event to log feedback for. This is the row `id` + * returned by `POST /v1/experiment/{experiment_id}/insert` */ fun id(): String = id.getRequired("id") /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event + * 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.getNullable("scores") /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ fun expected(): JsonValue = expected @@ -56,8 +72,8 @@ private constructor( fun comment(): String? = 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. + * 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. */ fun metadata(): Metadata? = metadata.getNullable("metadata") @@ -65,34 +81,46 @@ private constructor( fun source(): Source? = source.getNullable("source") /** - * 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() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores() = scores /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected /** An optional comment string to log about the experiment event */ - @JsonProperty("comment") @ExcludeMissing fun _comment() = comment + @JsonProperty("comment") + @ExcludeMissing + fun _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. + * 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. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source() = source + @JsonProperty("source") + @ExcludeMissing + fun _source() = source @JsonAnyGetter @ExcludeMissing @@ -100,51 +128,49 @@ private constructor( fun validate(): FeedbackExperimentItem = apply { if (!validated) { - id() - scores()?.validate() - expected() - comment() - metadata()?.validate() - source() - validated = true + id() + scores()?.validate() + expected() + comment() + metadata()?.validate() + source() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FeedbackExperimentItem && - this.id == other.id && - this.scores == other.scores && - this.expected == other.expected && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FeedbackExperimentItem && + this.id == other.id && + this.scores == other.scores && + this.expected == other.expected && + this.comment == other.comment && + this.metadata == other.metadata && + this.source == other.source && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - scores, - expected, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + scores, + expected, + comment, + metadata, + source, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackExperimentItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" companion object { @@ -172,38 +198,46 @@ private constructor( } /** - * The id of the experiment event to log feedback for. This is the row `id` returned by - * `POST /v1/experiment/{experiment_id}/insert` + * 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` */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the experiment event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the experiment event */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * 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(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = apply { + this.scores = scores + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** An optional comment string to log about the experiment event */ fun comment(comment: String) = comment(JsonField.of(comment)) @@ -211,21 +245,25 @@ private constructor( /** An optional comment string to log about the experiment event */ @JsonProperty("comment") @ExcludeMissing - 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. + * 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. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * 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. */ @JsonProperty("metadata") @ExcludeMissing - 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.of(source)) @@ -233,7 +271,9 @@ private constructor( /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing - fun source(source: JsonField) = apply { this.source = source } + fun source(source: JsonField) = apply { + this.source = source + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -249,28 +289,24 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FeedbackExperimentItem = - FeedbackExperimentItem( - id, - scores, - expected, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) + fun build(): FeedbackExperimentItem = FeedbackExperimentItem( + id, + scores, + expected, + comment, + metadata, + source, + additionalProperties.toUnmodifiable(), + ) } /** - * 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. + * 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. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -282,25 +318,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" @@ -337,15 +374,12 @@ 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 */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { + class Scores private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -357,25 +391,26 @@ private constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" @@ -411,20 +446,18 @@ private constructor( } } - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Source @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Source && this.value == other.value + return other is Source && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -455,21 +488,19 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + APP -> Value.APP + API -> Value.API + EXTERNAL -> Value.EXTERNAL + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } + fun known(): Known = when (this) { + APP -> Known.APP + API -> Known.API + EXTERNAL -> Known.EXTERNAL + else -> throw BraintrustInvalidDataException("Unknown Source: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequest.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequest.kt deleted file mode 100755 index a7c99430..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequest.kt +++ /dev/null @@ -1,114 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = FeedbackProjectLogsEventRequest.Builder::class) -@NoAutoDetect -class FeedbackProjectLogsEventRequest -private constructor( - private val feedback: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of project logs feedback items */ - fun feedback(): List = feedback.getRequired("feedback") - - /** A list of project logs feedback items */ - @JsonProperty("feedback") @ExcludeMissing fun _feedback() = feedback - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): FeedbackProjectLogsEventRequest = apply { - if (!validated) { - feedback().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FeedbackProjectLogsEventRequest && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode - } - - override fun toString() = - "FeedbackProjectLogsEventRequest{feedback=$feedback, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var feedback: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(feedbackProjectLogsEventRequest: FeedbackProjectLogsEventRequest) = - apply { - this.feedback = feedbackProjectLogsEventRequest.feedback - additionalProperties(feedbackProjectLogsEventRequest.additionalProperties) - } - - /** A list of project logs feedback items */ - fun feedback(feedback: List) = feedback(JsonField.of(feedback)) - - /** A list of project logs feedback items */ - @JsonProperty("feedback") - @ExcludeMissing - fun feedback(feedback: JsonField>) = apply { - this.feedback = feedback - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): FeedbackProjectLogsEventRequest = - FeedbackProjectLogsEventRequest( - feedback.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt index f9d74e8f..641a2286 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItem.kt @@ -2,32 +2,48 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = FeedbackProjectLogsItem.Builder::class) @NoAutoDetect -class FeedbackProjectLogsItem -private constructor( - private val id: JsonField, - private val scores: JsonField, - private val expected: JsonValue, - private val comment: JsonField, - private val metadata: JsonField, - private val source: JsonField, - private val additionalProperties: Map, +class FeedbackProjectLogsItem private constructor( + private val id: JsonField, + private val scores: JsonField, + private val expected: JsonValue, + private val comment: JsonField, + private val metadata: JsonField, + private val source: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -35,20 +51,20 @@ private constructor( private var hashCode: Int = 0 /** - * The id of the project logs event to log feedback for. This is the row `id` returned by `POST - * /v1/project_logs/{project_id}/insert` + * The id of the project logs event to log feedback for. This is the row `id` + * returned by `POST /v1/project_logs/{project_id}/insert` */ fun id(): String = id.getRequired("id") /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event + * 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.getNullable("scores") /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ fun expected(): JsonValue = expected @@ -56,8 +72,8 @@ private constructor( fun comment(): String? = 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. + * 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. */ fun metadata(): Metadata? = metadata.getNullable("metadata") @@ -65,34 +81,46 @@ private constructor( fun source(): Source? = source.getNullable("source") /** - * 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() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the - * existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores() = scores /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected /** An optional comment string to log about the project logs event */ - @JsonProperty("comment") @ExcludeMissing fun _comment() = comment + @JsonProperty("comment") + @ExcludeMissing + fun _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. + * 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. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ - @JsonProperty("source") @ExcludeMissing fun _source() = source + @JsonProperty("source") + @ExcludeMissing + fun _source() = source @JsonAnyGetter @ExcludeMissing @@ -100,51 +128,49 @@ private constructor( fun validate(): FeedbackProjectLogsItem = apply { if (!validated) { - id() - scores()?.validate() - expected() - comment() - metadata()?.validate() - source() - validated = true + id() + scores()?.validate() + expected() + comment() + metadata()?.validate() + source() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FeedbackProjectLogsItem && - this.id == other.id && - this.scores == other.scores && - this.expected == other.expected && - this.comment == other.comment && - this.metadata == other.metadata && - this.source == other.source && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FeedbackProjectLogsItem && + this.id == other.id && + this.scores == other.scores && + this.expected == other.expected && + this.comment == other.comment && + this.metadata == other.metadata && + this.source == other.source && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - scores, - expected, - comment, - metadata, - source, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + scores, + expected, + comment, + metadata, + source, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackProjectLogsItem{id=$id, scores=$scores, expected=$expected, comment=$comment, metadata=$metadata, source=$source, additionalProperties=$additionalProperties}" companion object { @@ -172,38 +198,46 @@ private constructor( } /** - * The id of the project logs event to log feedback for. This is the row `id` returned by - * `POST /v1/project_logs/{project_id}/insert` + * 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` */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** - * A dictionary of numeric values (between 0 and 1) to log. These scores will be merged into - * the existing scores for the project logs event + * A dictionary of numeric values (between 0 and 1) to log. These scores will be + * merged into the existing scores for the project logs event */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * 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(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = apply { + this.scores = scores + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** An optional comment string to log about the project logs event */ fun comment(comment: String) = comment(JsonField.of(comment)) @@ -211,21 +245,25 @@ private constructor( /** An optional comment string to log about the project logs event */ @JsonProperty("comment") @ExcludeMissing - 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. + * 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. */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the feedback. If you have a `user_id`, you can - * log it here and access it in the Braintrust UI. + * 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. */ @JsonProperty("metadata") @ExcludeMissing - 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.of(source)) @@ -233,7 +271,9 @@ private constructor( /** The source of the feedback. Must be one of "external" (default), "app", or "api" */ @JsonProperty("source") @ExcludeMissing - fun source(source: JsonField) = apply { this.source = source } + fun source(source: JsonField) = apply { + this.source = source + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -249,28 +289,24 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FeedbackProjectLogsItem = - FeedbackProjectLogsItem( - id, - scores, - expected, - comment, - metadata, - source, - additionalProperties.toUnmodifiable(), - ) + fun build(): FeedbackProjectLogsItem = FeedbackProjectLogsItem( + id, + scores, + expected, + comment, + metadata, + source, + additionalProperties.toUnmodifiable(), + ) } /** - * 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. + * 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. */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -282,25 +318,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" @@ -337,15 +374,12 @@ 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 */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { + class Scores private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -357,25 +391,26 @@ private constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" @@ -411,20 +446,18 @@ private constructor( } } - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Source @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Source && this.value == other.value + return other is Source && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -455,21 +488,19 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - APP -> Value.APP - API -> Value.API - EXTERNAL -> Value.EXTERNAL - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + APP -> Value.APP + API -> Value.API + EXTERNAL -> Value.EXTERNAL + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - APP -> Known.APP - API -> Known.API - EXTERNAL -> Known.EXTERNAL - else -> throw BraintrustInvalidDataException("Unknown Source: $value") - } + fun known(): Known = when (this) { + APP -> Known.APP + API -> Known.API + EXTERNAL -> Known.EXTERNAL + else -> throw BraintrustInvalidDataException("Unknown Source: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt index 032632d2..b7e5bdbf 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FeedbackResponseSchema.kt @@ -2,28 +2,40 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = FeedbackResponseSchema.Builder::class) @NoAutoDetect -class FeedbackResponseSchema -private constructor( - private val status: JsonField, - private val additionalProperties: Map, -) { +class FeedbackResponseSchema private constructor(private val status: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -31,7 +43,9 @@ private constructor( fun status(): Status = status.getRequired("status") - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") + @ExcludeMissing + fun _status() = status @JsonAnyGetter @ExcludeMissing @@ -39,32 +53,31 @@ private constructor( fun validate(): FeedbackResponseSchema = apply { if (!validated) { - status() - validated = true + status() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FeedbackResponseSchema && - this.status == other.status && - this.additionalProperties == other.additionalProperties + return other is FeedbackResponseSchema && + this.status == other.status && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(status, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(status, additionalProperties) + } + return hashCode } - override fun toString() = - "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" + override fun toString() = "FeedbackResponseSchema{status=$status, additionalProperties=$additionalProperties}" companion object { @@ -85,7 +98,9 @@ private constructor( @JsonProperty("status") @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } + fun status(status: JsonField) = apply { + this.status = status + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -101,24 +116,21 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FeedbackResponseSchema = - FeedbackResponseSchema(status, additionalProperties.toUnmodifiable()) + fun build(): FeedbackResponseSchema = FeedbackResponseSchema(status, additionalProperties.toUnmodifiable()) } - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Status @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Status && this.value == other.value + return other is Status && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -141,17 +153,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SUCCESS -> Value.SUCCESS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SUCCESS -> Known.SUCCESS - else -> throw BraintrustInvalidDataException("Unknown Status: $value") - } + fun value(): Value = when (this) { + SUCCESS -> Value.SUCCESS + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + SUCCESS -> Known.SUCCESS + else -> throw BraintrustInvalidDataException("Unknown Status: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt index aa79a366..19b29807 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponse.kt @@ -2,26 +2,40 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = FetchDatasetEventsResponse.Builder::class) @NoAutoDetect -class FetchDatasetEventsResponse -private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, -) { +class FetchDatasetEventsResponse private constructor(private val events: JsonField>, private val cursor: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -33,21 +47,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(): String? = cursor.getNullable("cursor") /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events() = 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() = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor() = cursor @JsonAnyGetter @ExcludeMissing @@ -55,39 +73,37 @@ private constructor( fun validate(): FetchDatasetEventsResponse = apply { if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + events().forEach { it.validate() } + cursor() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FetchDatasetEventsResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FetchDatasetEventsResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = "FetchDatasetEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" companion object { @@ -112,25 +128,29 @@ private constructor( /** A list of fetched events */ @JsonProperty("events") @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = 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. */ fun cursor(cursor: String) = cursor(JsonField.of(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. */ @JsonProperty("cursor") @ExcludeMissing - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + fun cursor(cursor: JsonField) = apply { + this.cursor = cursor + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -146,11 +166,10 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FetchDatasetEventsResponse = - FetchDatasetEventsResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) + fun build(): FetchDatasetEventsResponse = FetchDatasetEventsResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchEventsRequest.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchEventsRequest.kt deleted file mode 100755 index 924e77b6..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchEventsRequest.kt +++ /dev/null @@ -1,418 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = FetchEventsRequest.Builder::class) -@NoAutoDetect -class FetchEventsRequest -private constructor( - private val limit: JsonField, - private val cursor: JsonField, - private val maxXactId: JsonField, - private val maxRootSpanId: JsonField, - private val filters: JsonField>, - private val version: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. - */ - fun limit(): Long? = limit.getNullable("limit") - - /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. - * - * The string can be obtained directly from the `cursor` property of the previous fetch query - */ - fun cursor(): String? = cursor.getNullable("cursor") - - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the 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(): String? = maxXactId.getNullable("max_xact_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. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the 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(): String? = maxRootSpanId.getNullable("max_root_span_id") - - /** - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported, but we may add more in the future - */ - fun filters(): List? = filters.getNullable("filters") - - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. - */ - fun version(): String? = version.getNullable("version") - - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later - * pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. - * This happens because pagination occurs over the whole version history of the event log. You - * will most likely want to exclude any such duplicate, outdated rows (by `id`) from your - * combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up with - * more individual rows than the specified limit if you are fetching events containing traces. - */ - @JsonProperty("limit") @ExcludeMissing fun _limit() = limit - - /** - * An opaque string to be used as a cursor for the next page of results, in order from latest to - * earliest. - * - * The string can be obtained directly from the `cursor` property of the previous fetch query - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor - - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with 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() = maxXactId - - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the - * explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument - * going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the cursor - * for the next page can be found as the row with the minimum (earliest) value of the tuple - * `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating - * fetch queries. - */ - @JsonProperty("max_root_span_id") @ExcludeMissing fun _maxRootSpanId() = maxRootSpanId - - /** - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported, but we may add more in the future - */ - @JsonProperty("filters") @ExcludeMissing fun _filters() = filters - - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can use the - * `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. - */ - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): FetchEventsRequest = apply { - if (!validated) { - limit() - cursor() - maxXactId() - maxRootSpanId() - filters()?.forEach { it.validate() } - version() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FetchEventsRequest && - this.limit == other.limit && - this.cursor == other.cursor && - this.maxXactId == other.maxXactId && - this.maxRootSpanId == other.maxRootSpanId && - this.filters == other.filters && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - limit, - cursor, - maxXactId, - maxRootSpanId, - filters, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "FetchEventsRequest{limit=$limit, cursor=$cursor, maxXactId=$maxXactId, maxRootSpanId=$maxRootSpanId, filters=$filters, version=$version, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var limit: JsonField = JsonMissing.of() - private var cursor: JsonField = JsonMissing.of() - private var maxXactId: JsonField = JsonMissing.of() - private var maxRootSpanId: JsonField = JsonMissing.of() - private var filters: JsonField> = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(fetchEventsRequest: FetchEventsRequest) = apply { - this.limit = fetchEventsRequest.limit - this.cursor = fetchEventsRequest.cursor - this.maxXactId = fetchEventsRequest.maxXactId - this.maxRootSpanId = fetchEventsRequest.maxRootSpanId - this.filters = fetchEventsRequest.filters - this.version = fetchEventsRequest.version - additionalProperties(fetchEventsRequest.additionalProperties) - } - - /** - * limit the number of traces fetched - * - * Fetch queries may be paginated if the total result size is expected to be large (e.g. - * project_logs which accumulate over a long time). Note that fetch queries only support - * pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, - * later pages may return rows which showed up in earlier pages, except with an earlier - * `_xact_id`. This happens because pagination occurs over the whole version history of the - * event log. You will most likely want to exclude any such duplicate, outdated rows (by - * `id`) from your combined result set. - * - * The `limit` parameter controls the number of full traces to return. So you may end up - * with more individual rows than the specified limit if you are fetching events containing - * traces. - */ - fun limit(limit: Long) = limit(JsonField.of(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. - */ - @JsonProperty("limit") - @ExcludeMissing - fun limit(limit: JsonField) = apply { this.limit = limit } - - /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. - * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query - */ - fun cursor(cursor: String) = cursor(JsonField.of(cursor)) - - /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. - * - * The string can be obtained directly from the `cursor` property of the previous fetch - * query - */ - @JsonProperty("cursor") - @ExcludeMissing - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the 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.of(maxXactId)) - - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ - @JsonProperty("max_xact_id") - @ExcludeMissing - fun maxXactId(maxXactId: JsonField) = apply { this.maxXactId = maxXactId } - - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ - fun maxRootSpanId(maxRootSpanId: String) = maxRootSpanId(JsonField.of(maxRootSpanId)) - - /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. - * - * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor - * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. - */ - @JsonProperty("max_root_span_id") - @ExcludeMissing - fun maxRootSpanId(maxRootSpanId: JsonField) = apply { - this.maxRootSpanId = maxRootSpanId - } - - /** - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported, but we may add more in the future - */ - fun filters(filters: List) = filters(JsonField.of(filters)) - - /** - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported, but we may add more in the future - */ - @JsonProperty("filters") - @ExcludeMissing - fun filters(filters: JsonField>) = apply { this.filters = filters } - - /** - * Retrieve a snapshot of events from a past time - * - * The version id is essentially a filter on the latest event transaction id. You can use - * the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch. - */ - fun version(version: String) = version(JsonField.of(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. - */ - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): FetchEventsRequest = - FetchEventsRequest( - limit, - cursor, - maxXactId, - maxRootSpanId, - filters.map { it.toUnmodifiable() }, - version, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt index f680bafc..4627b7ce 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponse.kt @@ -2,26 +2,40 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = FetchExperimentEventsResponse.Builder::class) @NoAutoDetect -class FetchExperimentEventsResponse -private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, -) { +class FetchExperimentEventsResponse private constructor(private val events: JsonField>, private val cursor: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -33,21 +47,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(): String? = cursor.getNullable("cursor") /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events() = 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() = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor() = cursor @JsonAnyGetter @ExcludeMissing @@ -55,39 +73,37 @@ private constructor( fun validate(): FetchExperimentEventsResponse = apply { if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + events().forEach { it.validate() } + cursor() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FetchExperimentEventsResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FetchExperimentEventsResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = "FetchExperimentEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" companion object { @@ -112,25 +128,29 @@ private constructor( /** A list of fetched events */ @JsonProperty("events") @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = 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. */ fun cursor(cursor: String) = cursor(JsonField.of(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. */ @JsonProperty("cursor") @ExcludeMissing - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + fun cursor(cursor: JsonField) = apply { + this.cursor = cursor + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -146,11 +166,10 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FetchExperimentEventsResponse = - FetchExperimentEventsResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) + fun build(): FetchExperimentEventsResponse = FetchExperimentEventsResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt index cfb690b7..00a23f67 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponse.kt @@ -2,26 +2,40 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = FetchProjectLogsEventsResponse.Builder::class) @NoAutoDetect -class FetchProjectLogsEventsResponse -private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, -) { +class FetchProjectLogsEventsResponse private constructor(private val events: JsonField>, private val cursor: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -33,21 +47,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(): String? = cursor.getNullable("cursor") /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events() = 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() = cursor + @JsonProperty("cursor") + @ExcludeMissing + fun _cursor() = cursor @JsonAnyGetter @ExcludeMissing @@ -55,39 +73,37 @@ private constructor( fun validate(): FetchProjectLogsEventsResponse = apply { if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true + events().forEach { it.validate() } + cursor() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FetchProjectLogsEventsResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FetchProjectLogsEventsResponse && + this.events == other.events && + this.cursor == other.cursor && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + events, + cursor, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" + override fun toString() = "FetchProjectLogsEventsResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" companion object { @@ -112,25 +128,29 @@ private constructor( /** A list of fetched events */ @JsonProperty("events") @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = 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. */ fun cursor(cursor: String) = cursor(JsonField.of(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. */ @JsonProperty("cursor") @ExcludeMissing - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + fun cursor(cursor: JsonField) = apply { + this.cursor = cursor + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -146,11 +166,10 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FetchProjectLogsEventsResponse = - FetchProjectLogsEventsResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) + fun build(): FetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse( + events.map { it.toUnmodifiable() }, + cursor, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt index 3650f3cd..a1e854a3 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Function.kt @@ -2,51 +2,57 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect -class Function -private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val functionType: JsonField, - private val functionData: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, +class Function private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val projectId: JsonField, + private val logId: JsonField, + private val orgId: JsonField, + private val name: JsonField, + private val slug: JsonField, + private val description: JsonField, + private val created: JsonField, + private val promptData: JsonField, + private val tags: JsonField>, + private val metadata: JsonField, + private val functionType: JsonField, + private val functionData: JsonField, + private val origin: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -57,9 +63,10 @@ private constructor( 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") @@ -100,50 +107,81 @@ private constructor( fun origin(): Origin? = origin.getNullable("origin") /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _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) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId() = _xactId /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId() = projectId /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId + @JsonProperty("log_id") + @ExcludeMissing + fun _logId() = logId /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId() = orgId /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug() = slug /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description() = description /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData + @JsonProperty("prompt_data") + @ExcludeMissing + fun _promptData() = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata - @JsonProperty("function_type") @ExcludeMissing fun _functionType() = functionType + @JsonProperty("function_type") + @ExcludeMissing + fun _functionType() = functionType - @JsonProperty("function_data") @ExcludeMissing fun _functionData() = functionData + @JsonProperty("function_data") + @ExcludeMissing + fun _functionData() = functionData - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin() = origin @JsonAnyGetter @ExcludeMissing @@ -151,78 +189,76 @@ private constructor( fun validate(): Function = apply { if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData()?.validate() - tags() - metadata()?.validate() - functionType() - functionData() - origin()?.validate() - validated = true + id() + _xactId() + projectId() + logId() + orgId() + name() + slug() + description() + created() + promptData()?.validate() + tags() + metadata()?.validate() + functionType() + functionData() + origin()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.functionType == other.functionType && - this.functionData == other.functionData && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Function && + this.id == other.id && + this._xactId == other._xactId && + this.projectId == other.projectId && + this.logId == other.logId && + this.orgId == other.orgId && + this.name == other.name && + this.slug == other.slug && + this.description == other.description && + this.created == other.created && + this.promptData == other.promptData && + this.tags == other.tags && + this.metadata == other.metadata && + this.functionType == other.functionType && + this.functionData == other.functionData && + this.origin == other.origin && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - functionType, - functionData, - origin, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + _xactId, + projectId, + logId, + orgId, + name, + slug, + description, + created, + promptData, + tags, + metadata, + functionType, + functionData, + origin, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Function{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, functionData=$functionData, origin=$origin, additionalProperties=$additionalProperties}" + override fun toString() = "Function{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, functionData=$functionData, origin=$origin, additionalProperties=$additionalProperties}" companion object { @@ -271,23 +307,31 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + 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) */ @JsonProperty("_xact_id") @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = apply { + this._xactId = _xactId + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -295,7 +339,9 @@ private constructor( /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) @@ -303,7 +349,9 @@ private constructor( /** A literal 'p' which identifies the object as a project prompt */ @JsonProperty("log_id") @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } + fun logId(logId: JsonField) = apply { + this.logId = logId + } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -311,7 +359,9 @@ private constructor( /** Unique identifier for the organization */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = apply { + this.orgId = orgId + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) @@ -319,7 +369,9 @@ private constructor( /** Name of the prompt */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) @@ -327,7 +379,9 @@ private constructor( /** Unique identifier for the prompt */ @JsonProperty("slug") @ExcludeMissing - 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.of(description)) @@ -335,7 +389,9 @@ private constructor( /** Textual description of the prompt */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } /** Date of prompt creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -343,7 +399,9 @@ private constructor( /** Date of prompt creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) @@ -351,7 +409,9 @@ private constructor( /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @ExcludeMissing - 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.of(tags)) @@ -359,7 +419,9 @@ private constructor( /** A list of tags for the prompt */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) @@ -367,7 +429,9 @@ private constructor( /** User-controlled metadata about the prompt */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } fun functionType(functionType: FunctionType) = functionType(JsonField.of(functionType)) @@ -389,7 +453,9 @@ private constructor( @JsonProperty("origin") @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = apply { + this.origin = origin + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -405,107 +471,100 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Function = - Function( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags.map { it.toUnmodifiable() }, - metadata, - functionType, - functionData, - origin, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = Function( + id, + _xactId, + projectId, + logId, + orgId, + name, + slug, + description, + created, + promptData, + tags.map { it.toUnmodifiable() }, + metadata, + functionType, + functionData, + origin, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( - private val prompt: Prompt? = null, - private val code: Code? = null, - private val global: Global? = null, - private val _json: JsonValue? = null, + class FunctionData private constructor( + private val prompt: Prompt? = null, + private val code: Code? = null, + private val global: Global? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun prompt(): Prompt? = prompt - fun code(): Code? = code - fun global(): Global? = global fun isPrompt(): Boolean = prompt != null - fun isCode(): Boolean = code != null - fun isGlobal(): Boolean = global != null fun asPrompt(): Prompt = prompt.getOrThrow("prompt") - fun asCode(): Code = code.getOrThrow("code") - fun asGlobal(): Global = global.getOrThrow("global") fun _json(): JsonValue? = _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) + } } fun validate(): FunctionData = apply { if (!validated) { - if (prompt == null && code == null && global == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - prompt?.validate() - code?.validate() - global?.validate() - validated = true + if (prompt == null && code == null && global == null) { + throw BraintrustInvalidDataException("Unknown FunctionData: $_json") + } + prompt?.validate() + code?.validate() + global?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionData && - this.prompt == other.prompt && - this.code == other.code && - this.global == other.global + if (this === other) { + return true + } + + return other is FunctionData && + this.prompt == other.prompt && + this.code == other.code && + this.global == other.global } override fun hashCode(): Int { - return Objects.hash( - prompt, - code, - global, - ) + return Objects.hash( + prompt, + code, + global, + ) } override fun toString(): String { - return when { - prompt != null -> "FunctionData{prompt=$prompt}" - code != null -> "FunctionData{code=$code}" - global != null -> "FunctionData{global=$global}" - _json != null -> "FunctionData{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionData") - } + return when { + prompt != null -> "FunctionData{prompt=$prompt}" + code != null -> "FunctionData{code=$code}" + global != null -> "FunctionData{global=$global}" + _json != null -> "FunctionData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionData") + } } companion object { @@ -526,55 +585,44 @@ private constructor( fun visitGlobal(global: Global): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } 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) } } 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") + } } } @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect - class Prompt - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { + class Prompt private constructor(private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -582,7 +630,9 @@ private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -590,32 +640,31 @@ private constructor( fun validate(): Prompt = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Prompt && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Prompt && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" companion object { @@ -636,7 +685,9 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -648,28 +699,25 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -692,17 +740,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - PROMPT -> Value.PROMPT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + PROMPT -> Value.PROMPT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - PROMPT -> Known.PROMPT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + PROMPT -> Known.PROMPT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -710,12 +756,7 @@ private constructor( @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect - class Code - private constructor( - private val type: JsonField, - private val data: JsonField, - private val additionalProperties: Map, - ) { + class Code private constructor(private val type: JsonField, private val data: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -725,9 +766,13 @@ private constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") + @ExcludeMissing + fun _data() = data @JsonAnyGetter @ExcludeMissing @@ -735,39 +780,37 @@ private constructor( fun validate(): Code = apply { if (!validated) { - type() - data() - validated = true + type() + data() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Code && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Code && + this.type == other.type && + this.data == other.data && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + data, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" + override fun toString() = "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" companion object { @@ -790,13 +833,17 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun data(data: Data) = data(JsonField.of(data)) @JsonProperty("data") @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = apply { + this.data = data + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -808,84 +855,74 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Code = - Code( - type, - data, - additionalProperties.toUnmodifiable(), - ) + fun build(): Code = Code( + type, + data, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( - private val bundle: Bundle? = null, - private val inline: Inline? = null, - private val _json: JsonValue? = null, - ) { + class Data private constructor(private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun bundle(): Bundle? = bundle - fun inline(): Inline? = inline fun isBundle(): Boolean = bundle != null - fun isInline(): Boolean = inline != null fun asBundle(): Bundle = bundle.getOrThrow("bundle") - fun asInline(): Inline = inline.getOrThrow("inline") fun _json(): JsonValue? = _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) + } } fun validate(): Data = apply { if (!validated) { - if (bundle == null && inline == null) { - throw BraintrustInvalidDataException("Unknown Data: $_json") - } - bundle?.validate() - inline?.validate() - validated = true + if (bundle == null && inline == null) { + throw BraintrustInvalidDataException("Unknown Data: $_json") + } + bundle?.validate() + inline?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Data && - this.bundle == other.bundle && - this.inline == other.inline + return other is Data && + this.bundle == other.bundle && + this.inline == other.inline } override fun hashCode(): Int { - return Objects.hash(bundle, inline) + return Objects.hash(bundle, inline) } override fun toString(): String { - return when { - bundle != null -> "Data{bundle=$bundle}" - inline != null -> "Data{inline=$inline}" - _json != null -> "Data{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Data") - } + return when { + bundle != null -> "Data{bundle=$bundle}" + inline != null -> "Data{inline=$inline}" + _json != null -> "Data{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Data") + } } companion object { @@ -902,53 +939,47 @@ private constructor( fun visitInline(inline: Inline): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - 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) - } - - return Data(_json = json) + 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) + } + + return Data(_json = json) } } 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") + } } } @JsonDeserialize(builder = Bundle.Builder::class) @NoAutoDetect - class Bundle - private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val preview: JsonField, - private val additionalProperties: Map, + class Bundle private constructor( + private val type: JsonField, + private val runtimeContext: JsonField, + private val location: JsonField, + private val bundleId: JsonField, + private val preview: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -957,8 +988,7 @@ private constructor( fun type(): Type = type.getRequired("type") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun location(): Location = location.getRequired("location") @@ -967,18 +997,26 @@ private constructor( /** A preview of the code */ fun preview(): String? = preview.getNullable("preview") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") + @ExcludeMissing + fun _location() = location - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + @JsonProperty("bundle_id") + @ExcludeMissing + fun _bundleId() = bundleId /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview() = preview + @JsonProperty("preview") + @ExcludeMissing + fun _preview() = preview @JsonAnyGetter @ExcludeMissing @@ -986,48 +1024,46 @@ private constructor( fun validate(): Bundle = apply { if (!validated) { - type() - runtimeContext().validate() - location().validate() - bundleId() - preview() - validated = true + type() + runtimeContext().validate() + location().validate() + bundleId() + preview() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Bundle && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.preview == other.preview && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Bundle && + this.type == other.type && + this.runtimeContext == other.runtimeContext && + this.location == other.location && + this.bundleId == other.bundleId && + this.preview == other.preview && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - location, - bundleId, - preview, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + runtimeContext, + location, + bundleId, + preview, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Bundle{type=$type, runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{type=$type, runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" companion object { @@ -1041,8 +1077,7 @@ private constructor( private var location: JsonField = JsonMissing.of() private var bundleId: JsonField = JsonMissing.of() private var preview: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bundle: Bundle) = apply { this.type = bundle.type @@ -1057,10 +1092,11 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -1090,42 +1126,42 @@ private constructor( /** A preview of the code */ @JsonProperty("preview") @ExcludeMissing - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = apply { + this.preview = preview + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Bundle = - Bundle( - type, - runtimeContext, - location, - bundleId, - preview, - additionalProperties.toUnmodifiable(), - ) + fun build(): Bundle = Bundle( + type, + runtimeContext, + location, + bundleId, + preview, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Location.Builder::class) @NoAutoDetect - class Location - private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + class Location private constructor( + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1138,11 +1174,17 @@ private constructor( fun position(): Position = position.getRequired("position") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + @JsonProperty("eval_name") + @ExcludeMissing + fun _evalName() = evalName - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("position") + @ExcludeMissing + fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -1150,42 +1192,40 @@ private constructor( fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() - validated = true + type() + evalName() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Location && + this.type == other.type && + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + evalName, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" companion object { @@ -1197,8 +1237,7 @@ private constructor( private var type: JsonField = JsonMissing.of() private var evalName: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(location: Location) = apply { this.type = location.type @@ -1211,7 +1250,9 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) @@ -1229,97 +1270,85 @@ private constructor( this.position = position } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Location = - Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Location = Location( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position - private constructor( - private val type: Type? = null, - private val scorer: Scorer? = null, - private val _json: JsonValue? = null, - ) { + class Position private constructor(private val type: Type? = null, private val scorer: Scorer? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun type(): Type? = type - fun scorer(): Scorer? = scorer fun isType(): Boolean = type != null - fun isScorer(): Boolean = scorer != null fun asType(): Type = type.getOrThrow("type") - fun asScorer(): Scorer = scorer.getOrThrow("scorer") fun _json(): JsonValue? = _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) + } } fun validate(): Position = apply { if (!validated) { - if (type == null && scorer == null) { - throw BraintrustInvalidDataException( - "Unknown Position: $_json" - ) - } - type?.validate() - scorer?.validate() - validated = true + if (type == null && scorer == null) { + throw BraintrustInvalidDataException("Unknown Position: $_json") + } + type?.validate() + scorer?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Position && - this.type == other.type && - this.scorer == other.scorer + return other is Position && + this.type == other.type && + this.scorer == other.scorer } override fun hashCode(): Int { - return Objects.hash(type, scorer) + return Objects.hash(type, scorer) } override fun toString(): String { - return when { - type != null -> "Position{type=$type}" - scorer != null -> "Position{scorer=$scorer}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") - } + return when { + type != null -> "Position{type=$type}" + scorer != null -> "Position{scorer=$scorer}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } } companion object { @@ -1336,50 +1365,40 @@ private constructor( fun visitScorer(scorer: Scorer): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - 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) - } - - return Position(_json = json) + 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) + } + + return Position(_json = json) } } 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") + } } } @JsonDeserialize(builder = Type.Builder::class) @NoAutoDetect - class Type - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { + class Type private constructor(private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1387,41 +1406,41 @@ private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Type = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Type && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1431,9 +1450,7 @@ private constructor( class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(type: Type) = apply { this.type = type.type @@ -1444,46 +1461,39 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Type = - Type(type, additionalProperties.toUnmodifiable()) + fun build(): Type = Type(type, additionalProperties.toUnmodifiable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1506,20 +1516,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } + fun value(): Value = when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + TASK -> Known.TASK + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1527,12 +1532,7 @@ private constructor( @JsonDeserialize(builder = Scorer.Builder::class) @NoAutoDetect - class Scorer - private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, - ) { + class Scorer private constructor(private val type: JsonField, private val index: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1542,50 +1542,51 @@ private constructor( fun index(): Double = index.getRequired("index") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("index") @ExcludeMissing fun _index() = index + @JsonProperty("index") + @ExcludeMissing + fun _index() = index @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Scorer = apply { if (!validated) { - type() - index() - validated = true + type() + index() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scorer && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Scorer && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + index, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + override fun toString() = "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" companion object { @@ -1596,9 +1597,7 @@ private constructor( private var type: JsonField = JsonMissing.of() private var index: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(scorer: Scorer) = apply { this.type = scorer.type @@ -1610,7 +1609,9 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun index(index: Double) = index(JsonField.of(index)) @@ -1620,48 +1621,39 @@ private constructor( this.index = index } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Scorer = - Scorer( - type, - index, - additionalProperties.toUnmodifiable(), - ) + fun build(): Scorer = Scorer( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1684,41 +1676,33 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SCORER -> Known.SCORER - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } + fun value(): Value = when (this) { + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1741,18 +1725,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + EXPERIMENT -> Value.EXPERIMENT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + EXPERIMENT -> Known.EXPERIMENT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1760,12 +1741,7 @@ private constructor( @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext - private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, - ) { + class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1775,9 +1751,13 @@ private constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime() = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -1785,39 +1765,37 @@ private constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -1828,8 +1806,7 @@ private constructor( private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(runtimeContext: RuntimeContext) = apply { this.runtime = runtimeContext.runtime @@ -1853,44 +1830,39 @@ private constructor( this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): RuntimeContext = - RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && this.value == other.value + return other is Runtime && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1917,42 +1889,34 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - NODE -> Value.NODE - PYTHON -> Value.PYTHON - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + NODE -> Value.NODE + PYTHON -> Value.PYTHON + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - NODE -> Known.NODE - PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) - } + fun known(): Known = when (this) { + NODE -> Known.NODE + PYTHON -> Known.PYTHON + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1975,17 +1939,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - BUNDLE -> Value.BUNDLE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + BUNDLE -> Value.BUNDLE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - BUNDLE -> Known.BUNDLE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + BUNDLE -> Known.BUNDLE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1993,12 +1955,12 @@ private constructor( @JsonDeserialize(builder = Inline.Builder::class) @NoAutoDetect - class Inline - private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val code: JsonField, - private val additionalProperties: Map, + class Inline private constructor( + private val type: JsonField, + private val runtimeContext: JsonField, + private val code: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2007,18 +1969,21 @@ private constructor( fun type(): Type = type.getRequired("type") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun code(): String = code.getRequired("code") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") + @ExcludeMissing + fun _code() = code @JsonAnyGetter @ExcludeMissing @@ -2026,42 +1991,40 @@ private constructor( fun validate(): Inline = apply { if (!validated) { - type() - runtimeContext().validate() - code() - validated = true + type() + runtimeContext().validate() + code() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Inline && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.code == other.code && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Inline && + this.type == other.type && + this.runtimeContext == other.runtimeContext && + this.code == other.code && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - code, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + runtimeContext, + code, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" companion object { @@ -2073,8 +2036,7 @@ private constructor( private var type: JsonField = JsonMissing.of() private var runtimeContext: JsonField = JsonMissing.of() private var code: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(inline: Inline) = apply { this.type = inline.type @@ -2087,10 +2049,11 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -2102,40 +2065,35 @@ private constructor( @JsonProperty("code") @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = apply { + this.code = code + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Inline = - Inline( - type, - runtimeContext, - code, - additionalProperties.toUnmodifiable(), - ) + fun build(): Inline = Inline( + type, + runtimeContext, + code, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext - private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, - ) { + class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2145,9 +2103,13 @@ private constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime() = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -2155,39 +2117,37 @@ private constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -2198,8 +2158,7 @@ private constructor( private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(runtimeContext: RuntimeContext) = apply { this.runtime = runtimeContext.runtime @@ -2223,44 +2182,39 @@ private constructor( this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): RuntimeContext = - RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && this.value == other.value + return other is Runtime && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2287,42 +2241,34 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - NODE -> Value.NODE - PYTHON -> Value.PYTHON - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + NODE -> Value.NODE + PYTHON -> Value.PYTHON + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - NODE -> Known.NODE - PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) - } + fun known(): Known = when (this) { + NODE -> Known.NODE + PYTHON -> Known.PYTHON + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2345,37 +2291,33 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - INLINE -> Value.INLINE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + INLINE -> Value.INLINE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - INLINE -> Known.INLINE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + INLINE -> Known.INLINE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2398,17 +2340,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CODE -> Value.CODE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + CODE -> Value.CODE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - CODE -> Known.CODE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + CODE -> Known.CODE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2416,12 +2356,7 @@ private constructor( @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect - class Global - private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { + class Global private constructor(private val type: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2431,9 +2366,13 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing @@ -2441,39 +2380,37 @@ private constructor( fun validate(): Global = apply { if (!validated) { - type() - name() - validated = true + type() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -2496,13 +2433,17 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2514,33 +2455,29 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Global = - Global( - type, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Global = Global( + type, + name, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2563,37 +2500,33 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class LogId @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is LogId && this.value == other.value + return other is LogId && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2616,35 +2549,31 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - P -> Value.P - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + P -> Value.P + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - P -> Known.P - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } + fun known(): Known = when (this) { + P -> Known.P + else -> throw BraintrustInvalidDataException("Unknown LogId: $value") + } fun asString(): String = _value().asStringOrThrow() } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionType && this.value == other.value + return other is FunctionType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2675,21 +2604,19 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TASK -> Value.TASK - LLM -> Value.LLM - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + TASK -> Value.TASK + LLM -> Value.LLM + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - TASK -> Known.TASK - LLM -> Known.LLM - SCORER -> Known.SCORER - else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") - } + fun known(): Known = when (this) { + TASK -> Known.TASK + LLM -> Known.LLM + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2697,10 +2624,7 @@ private constructor( /** User-controlled metadata about the prompt */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2712,25 +2636,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" @@ -2768,12 +2693,12 @@ private constructor( @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin - private constructor( - private val objectType: JsonField, - private val objectId: JsonField, - private val internal_: JsonField, - private val additionalProperties: Map, + class Origin private constructor( + private val objectType: JsonField, + private val objectId: JsonField, + private val internal_: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2787,22 +2712,28 @@ private constructor( fun objectId(): String = objectId.getRequired("object_id") /** - * 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_(): Boolean? = internal_.getNullable("internal") /** The object type that the ACL applies to */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType() = objectType /** Id of the object the function is originating from */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId() = objectId /** - * 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_() = internal_ + @JsonProperty("internal") + @ExcludeMissing + fun _internal_() = internal_ @JsonAnyGetter @ExcludeMissing @@ -2810,42 +2741,40 @@ private constructor( fun validate(): Origin = apply { if (!validated) { - objectType() - objectId() - internal_() - validated = true + objectType() + objectId() + internal_() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.internal_ == other.internal_ && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.internal_ == other.internal_ && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - internal_, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + objectType, + objectId, + internal_, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" companion object { @@ -2882,21 +2811,25 @@ private constructor( /** Id of the object the function is originating from */ @JsonProperty("object_id") @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = apply { + this.objectId = objectId + } /** - * 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.of(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. */ @JsonProperty("internal") @ExcludeMissing - fun internal_(internal_: JsonField) = apply { this.internal_ = internal_ } + fun internal_(internal_: JsonField) = apply { + this.internal_ = internal_ + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2912,29 +2845,26 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Origin = - Origin( - objectType, - objectId, - internal_, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = Origin( + objectType, + objectId, + internal_, + additionalProperties.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2997,37 +2927,35 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt index e9a1019f..e775b507 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionCreateParams.kt @@ -2,45 +2,54 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class FunctionCreateParams constructor( + private val functionData: FunctionData, + private val name: String, + private val projectId: String, + private val slug: String, + private val description: String?, + private val functionType: FunctionType?, + private val origin: Origin?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class FunctionCreateParams -constructor( - private val functionData: FunctionData, - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val functionType: FunctionType?, - private val origin: Origin?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun functionData(): FunctionData = functionData @@ -62,18 +71,18 @@ constructor( fun tags(): List? = tags internal fun getBody(): FunctionCreateBody { - return FunctionCreateBody( - functionData, - name, - projectId, - slug, - description, - functionType, - origin, - promptData, - tags, - additionalBodyProperties, - ) + return FunctionCreateBody( + functionData, + name, + projectId, + slug, + description, + functionType, + origin, + promptData, + tags, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -82,45 +91,54 @@ constructor( @JsonDeserialize(builder = FunctionCreateBody.Builder::class) @NoAutoDetect - class FunctionCreateBody - internal constructor( - private val functionData: FunctionData?, - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val functionType: FunctionType?, - private val origin: Origin?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, + class FunctionCreateBody internal constructor( + private val functionData: FunctionData?, + private val name: String?, + private val projectId: String?, + private val slug: String?, + private val description: String?, + private val functionType: FunctionType?, + private val origin: Origin?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 - @JsonProperty("function_data") fun functionData(): FunctionData? = functionData + @JsonProperty("function_data") + fun functionData(): FunctionData? = functionData /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") + fun projectId(): String? = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(): String? = slug + @JsonProperty("slug") + fun slug(): String? = slug /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description - @JsonProperty("function_type") fun functionType(): FunctionType? = functionType + @JsonProperty("function_type") + fun functionType(): FunctionType? = functionType - @JsonProperty("origin") fun origin(): Origin? = origin + @JsonProperty("origin") + fun origin(): Origin? = origin /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") + fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -129,44 +147,42 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCreateBody && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.origin == other.origin && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FunctionCreateBody && + this.functionData == other.functionData && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.functionType == other.functionType && + this.origin == other.origin && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - functionData, - name, - projectId, - slug, - description, - functionType, - origin, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + functionData, + name, + projectId, + slug, + description, + functionType, + origin, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionCreateBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { @@ -205,32 +221,50 @@ constructor( } /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } + @JsonProperty("slug") + fun slug(slug: String) = apply { + this.slug = slug + } /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } @JsonProperty("function_type") fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } - @JsonProperty("origin") fun origin(origin: Origin) = apply { this.origin = origin } + @JsonProperty("origin") + fun origin(origin: Origin) = apply { + this.origin = origin + } /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + @JsonProperty("tags") + fun tags(tags: List) = apply { + this.tags = tags + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -246,19 +280,26 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionCreateBody = - FunctionCreateBody( - checkNotNull(functionData) { "`functionData` is required but was not set" }, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionType, - origin, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCreateBody = FunctionCreateBody( + checkNotNull(functionData) { + "`functionData` is required but was not set" + }, + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + checkNotNull(slug) { + "`slug` is required but was not set" + }, + description, + functionType, + origin, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -269,44 +310,43 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionCreateParams && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.origin == other.origin && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is FunctionCreateParams && + this.functionData == other.functionData && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.functionType == other.functionType && + this.origin == other.origin && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - functionData, - name, - projectId, - slug, - description, - functionType, - origin, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + functionData, + name, + projectId, + slug, + description, + functionType, + origin, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "FunctionCreateParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -346,7 +386,9 @@ constructor( additionalBodyProperties(functionCreateParams.additionalBodyProperties) } - fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } + fun functionData(functionData: FunctionData) = apply { + this.functionData = functionData + } fun functionData(prompt: FunctionData.Prompt) = apply { this.functionData = FunctionData.ofPrompt(prompt) @@ -361,23 +403,37 @@ constructor( } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: String) = apply { + this.slug = slug + } /** Textual description of the prompt */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } - fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } + fun functionType(functionType: FunctionType) = apply { + this.functionType = functionType + } - fun origin(origin: Origin) = apply { this.origin = origin } + fun origin(origin: Origin) = apply { + this.origin = origin + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -386,7 +442,9 @@ constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun addTag(tag: String) = apply { + this.tags.add(tag) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -426,7 +484,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -437,108 +497,108 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): FunctionCreateParams = - FunctionCreateParams( - checkNotNull(functionData) { "`functionData` is required but was not set" }, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionType, - origin, - promptData, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): FunctionCreateParams = FunctionCreateParams( + checkNotNull(functionData) { + "`functionData` is required but was not set" + }, + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + checkNotNull(slug) { + "`slug` is required but was not set" + }, + description, + functionType, + origin, + promptData, + if(tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( - private val prompt: Prompt? = null, - private val code: Code? = null, - private val global: Global? = null, - private val _json: JsonValue? = null, + class FunctionData private constructor( + private val prompt: Prompt? = null, + private val code: Code? = null, + private val global: Global? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun prompt(): Prompt? = prompt - fun code(): Code? = code - fun global(): Global? = global fun isPrompt(): Boolean = prompt != null - fun isCode(): Boolean = code != null - fun isGlobal(): Boolean = global != null fun asPrompt(): Prompt = prompt.getOrThrow("prompt") - fun asCode(): Code = code.getOrThrow("code") - fun asGlobal(): Global = global.getOrThrow("global") fun _json(): JsonValue? = _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) + } } fun validate(): FunctionData = apply { if (!validated) { - if (prompt == null && code == null && global == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - prompt?.validate() - code?.validate() - global?.validate() - validated = true + if (prompt == null && code == null && global == null) { + throw BraintrustInvalidDataException("Unknown FunctionData: $_json") + } + prompt?.validate() + code?.validate() + global?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionData && - this.prompt == other.prompt && - this.code == other.code && - this.global == other.global + if (this === other) { + return true + } + + return other is FunctionData && + this.prompt == other.prompt && + this.code == other.code && + this.global == other.global } override fun hashCode(): Int { - return Objects.hash( - prompt, - code, - global, - ) + return Objects.hash( + prompt, + code, + global, + ) } override fun toString(): String { - return when { - prompt != null -> "FunctionData{prompt=$prompt}" - code != null -> "FunctionData{code=$code}" - global != null -> "FunctionData{global=$global}" - _json != null -> "FunctionData{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionData") - } + return when { + prompt != null -> "FunctionData{prompt=$prompt}" + code != null -> "FunctionData{code=$code}" + global != null -> "FunctionData{global=$global}" + _json != null -> "FunctionData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionData") + } } companion object { @@ -559,55 +619,44 @@ constructor( fun visitGlobal(global: Global): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } 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) } } 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") + } } } @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect - class Prompt - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { + class Prompt private constructor(private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -615,7 +664,9 @@ constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -623,32 +674,31 @@ constructor( fun validate(): Prompt = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Prompt && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Prompt && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" companion object { @@ -669,7 +719,9 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -681,28 +733,25 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -725,17 +774,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - PROMPT -> Value.PROMPT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + PROMPT -> Value.PROMPT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - PROMPT -> Known.PROMPT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + PROMPT -> Known.PROMPT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -743,12 +790,7 @@ constructor( @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect - class Code - private constructor( - private val type: JsonField, - private val data: JsonField, - private val additionalProperties: Map, - ) { + class Code private constructor(private val type: JsonField, private val data: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -758,9 +800,13 @@ constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") + @ExcludeMissing + fun _data() = data @JsonAnyGetter @ExcludeMissing @@ -768,39 +814,37 @@ constructor( fun validate(): Code = apply { if (!validated) { - type() - data() - validated = true + type() + data() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Code && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Code && + this.type == other.type && + this.data == other.data && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + data, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" + override fun toString() = "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" companion object { @@ -823,13 +867,17 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun data(data: Data) = data(JsonField.of(data)) @JsonProperty("data") @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = apply { + this.data = data + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -841,84 +889,74 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Code = - Code( - type, - data, - additionalProperties.toUnmodifiable(), - ) + fun build(): Code = Code( + type, + data, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( - private val bundle: Bundle? = null, - private val inline: Inline? = null, - private val _json: JsonValue? = null, - ) { + class Data private constructor(private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun bundle(): Bundle? = bundle - fun inline(): Inline? = inline fun isBundle(): Boolean = bundle != null - fun isInline(): Boolean = inline != null fun asBundle(): Bundle = bundle.getOrThrow("bundle") - fun asInline(): Inline = inline.getOrThrow("inline") fun _json(): JsonValue? = _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) + } } fun validate(): Data = apply { if (!validated) { - if (bundle == null && inline == null) { - throw BraintrustInvalidDataException("Unknown Data: $_json") - } - bundle?.validate() - inline?.validate() - validated = true + if (bundle == null && inline == null) { + throw BraintrustInvalidDataException("Unknown Data: $_json") + } + bundle?.validate() + inline?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Data && - this.bundle == other.bundle && - this.inline == other.inline + return other is Data && + this.bundle == other.bundle && + this.inline == other.inline } override fun hashCode(): Int { - return Objects.hash(bundle, inline) + return Objects.hash(bundle, inline) } override fun toString(): String { - return when { - bundle != null -> "Data{bundle=$bundle}" - inline != null -> "Data{inline=$inline}" - _json != null -> "Data{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Data") - } + return when { + bundle != null -> "Data{bundle=$bundle}" + inline != null -> "Data{inline=$inline}" + _json != null -> "Data{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Data") + } } companion object { @@ -935,53 +973,47 @@ constructor( fun visitInline(inline: Inline): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - 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) - } - - return Data(_json = json) + 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) + } + + return Data(_json = json) } } 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") + } } } @JsonDeserialize(builder = Bundle.Builder::class) @NoAutoDetect - class Bundle - private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val preview: JsonField, - private val additionalProperties: Map, + class Bundle private constructor( + private val type: JsonField, + private val runtimeContext: JsonField, + private val location: JsonField, + private val bundleId: JsonField, + private val preview: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -990,8 +1022,7 @@ constructor( fun type(): Type = type.getRequired("type") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun location(): Location = location.getRequired("location") @@ -1000,18 +1031,26 @@ constructor( /** A preview of the code */ fun preview(): String? = preview.getNullable("preview") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") + @ExcludeMissing + fun _location() = location - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + @JsonProperty("bundle_id") + @ExcludeMissing + fun _bundleId() = bundleId /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview() = preview + @JsonProperty("preview") + @ExcludeMissing + fun _preview() = preview @JsonAnyGetter @ExcludeMissing @@ -1019,48 +1058,46 @@ constructor( fun validate(): Bundle = apply { if (!validated) { - type() - runtimeContext().validate() - location().validate() - bundleId() - preview() - validated = true + type() + runtimeContext().validate() + location().validate() + bundleId() + preview() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Bundle && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.preview == other.preview && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Bundle && + this.type == other.type && + this.runtimeContext == other.runtimeContext && + this.location == other.location && + this.bundleId == other.bundleId && + this.preview == other.preview && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - location, - bundleId, - preview, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + runtimeContext, + location, + bundleId, + preview, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Bundle{type=$type, runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{type=$type, runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" companion object { @@ -1074,8 +1111,7 @@ constructor( private var location: JsonField = JsonMissing.of() private var bundleId: JsonField = JsonMissing.of() private var preview: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bundle: Bundle) = apply { this.type = bundle.type @@ -1090,10 +1126,11 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -1123,42 +1160,42 @@ constructor( /** A preview of the code */ @JsonProperty("preview") @ExcludeMissing - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = apply { + this.preview = preview + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Bundle = - Bundle( - type, - runtimeContext, - location, - bundleId, - preview, - additionalProperties.toUnmodifiable(), - ) + fun build(): Bundle = Bundle( + type, + runtimeContext, + location, + bundleId, + preview, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Location.Builder::class) @NoAutoDetect - class Location - private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + class Location private constructor( + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1171,11 +1208,17 @@ constructor( fun position(): Position = position.getRequired("position") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + @JsonProperty("eval_name") + @ExcludeMissing + fun _evalName() = evalName - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("position") + @ExcludeMissing + fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -1183,42 +1226,40 @@ constructor( fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() - validated = true + type() + evalName() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Location && + this.type == other.type && + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + evalName, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" companion object { @@ -1230,8 +1271,7 @@ constructor( private var type: JsonField = JsonMissing.of() private var evalName: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(location: Location) = apply { this.type = location.type @@ -1244,7 +1284,9 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) @@ -1262,97 +1304,85 @@ constructor( this.position = position } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Location = - Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Location = Location( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position - private constructor( - private val type: Type? = null, - private val scorer: Scorer? = null, - private val _json: JsonValue? = null, - ) { + class Position private constructor(private val type: Type? = null, private val scorer: Scorer? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun type(): Type? = type - fun scorer(): Scorer? = scorer fun isType(): Boolean = type != null - fun isScorer(): Boolean = scorer != null fun asType(): Type = type.getOrThrow("type") - fun asScorer(): Scorer = scorer.getOrThrow("scorer") fun _json(): JsonValue? = _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) + } } fun validate(): Position = apply { if (!validated) { - if (type == null && scorer == null) { - throw BraintrustInvalidDataException( - "Unknown Position: $_json" - ) - } - type?.validate() - scorer?.validate() - validated = true + if (type == null && scorer == null) { + throw BraintrustInvalidDataException("Unknown Position: $_json") + } + type?.validate() + scorer?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Position && - this.type == other.type && - this.scorer == other.scorer + return other is Position && + this.type == other.type && + this.scorer == other.scorer } override fun hashCode(): Int { - return Objects.hash(type, scorer) + return Objects.hash(type, scorer) } override fun toString(): String { - return when { - type != null -> "Position{type=$type}" - scorer != null -> "Position{scorer=$scorer}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") - } + return when { + type != null -> "Position{type=$type}" + scorer != null -> "Position{scorer=$scorer}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } } companion object { @@ -1369,50 +1399,40 @@ constructor( fun visitScorer(scorer: Scorer): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - 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) - } - - return Position(_json = json) + 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) + } + + return Position(_json = json) } } 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") + } } } @JsonDeserialize(builder = Type.Builder::class) @NoAutoDetect - class Type - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { + class Type private constructor(private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1420,41 +1440,41 @@ constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Type = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Type && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1464,9 +1484,7 @@ constructor( class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(type: Type) = apply { this.type = type.type @@ -1477,46 +1495,39 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Type = - Type(type, additionalProperties.toUnmodifiable()) + fun build(): Type = Type(type, additionalProperties.toUnmodifiable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1539,20 +1550,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } + fun value(): Value = when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + TASK -> Known.TASK + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1560,12 +1566,7 @@ constructor( @JsonDeserialize(builder = Scorer.Builder::class) @NoAutoDetect - class Scorer - private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, - ) { + class Scorer private constructor(private val type: JsonField, private val index: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1575,50 +1576,51 @@ constructor( fun index(): Double = index.getRequired("index") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("index") @ExcludeMissing fun _index() = index + @JsonProperty("index") + @ExcludeMissing + fun _index() = index @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Scorer = apply { if (!validated) { - type() - index() - validated = true + type() + index() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scorer && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Scorer && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + index, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + override fun toString() = "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" companion object { @@ -1629,9 +1631,7 @@ constructor( private var type: JsonField = JsonMissing.of() private var index: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(scorer: Scorer) = apply { this.type = scorer.type @@ -1643,7 +1643,9 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun index(index: Double) = index(JsonField.of(index)) @@ -1653,48 +1655,39 @@ constructor( this.index = index } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Scorer = - Scorer( - type, - index, - additionalProperties.toUnmodifiable(), - ) + fun build(): Scorer = Scorer( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1717,41 +1710,33 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SCORER -> Known.SCORER - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } + fun value(): Value = when (this) { + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1774,18 +1759,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + EXPERIMENT -> Value.EXPERIMENT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + EXPERIMENT -> Known.EXPERIMENT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1793,12 +1775,7 @@ constructor( @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext - private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, - ) { + class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1808,9 +1785,13 @@ constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime() = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -1818,39 +1799,37 @@ constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -1861,8 +1840,7 @@ constructor( private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(runtimeContext: RuntimeContext) = apply { this.runtime = runtimeContext.runtime @@ -1886,44 +1864,39 @@ constructor( this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): RuntimeContext = - RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && this.value == other.value + return other is Runtime && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1950,42 +1923,34 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - NODE -> Value.NODE - PYTHON -> Value.PYTHON - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + NODE -> Value.NODE + PYTHON -> Value.PYTHON + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - NODE -> Known.NODE - PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) - } + fun known(): Known = when (this) { + NODE -> Known.NODE + PYTHON -> Known.PYTHON + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2008,17 +1973,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - BUNDLE -> Value.BUNDLE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + BUNDLE -> Value.BUNDLE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - BUNDLE -> Known.BUNDLE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + BUNDLE -> Known.BUNDLE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2026,12 +1989,12 @@ constructor( @JsonDeserialize(builder = Inline.Builder::class) @NoAutoDetect - class Inline - private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val code: JsonField, - private val additionalProperties: Map, + class Inline private constructor( + private val type: JsonField, + private val runtimeContext: JsonField, + private val code: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2040,18 +2003,21 @@ constructor( fun type(): Type = type.getRequired("type") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun code(): String = code.getRequired("code") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") + @ExcludeMissing + fun _code() = code @JsonAnyGetter @ExcludeMissing @@ -2059,42 +2025,40 @@ constructor( fun validate(): Inline = apply { if (!validated) { - type() - runtimeContext().validate() - code() - validated = true + type() + runtimeContext().validate() + code() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Inline && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.code == other.code && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Inline && + this.type == other.type && + this.runtimeContext == other.runtimeContext && + this.code == other.code && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - code, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + runtimeContext, + code, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" companion object { @@ -2106,8 +2070,7 @@ constructor( private var type: JsonField = JsonMissing.of() private var runtimeContext: JsonField = JsonMissing.of() private var code: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(inline: Inline) = apply { this.type = inline.type @@ -2120,10 +2083,11 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -2135,40 +2099,35 @@ constructor( @JsonProperty("code") @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = apply { + this.code = code + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Inline = - Inline( - type, - runtimeContext, - code, - additionalProperties.toUnmodifiable(), - ) + fun build(): Inline = Inline( + type, + runtimeContext, + code, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext - private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, - ) { + class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2178,9 +2137,13 @@ constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime() = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -2188,39 +2151,37 @@ constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -2231,8 +2192,7 @@ constructor( private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(runtimeContext: RuntimeContext) = apply { this.runtime = runtimeContext.runtime @@ -2256,44 +2216,39 @@ constructor( this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): RuntimeContext = - RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && this.value == other.value + return other is Runtime && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2320,42 +2275,34 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - NODE -> Value.NODE - PYTHON -> Value.PYTHON - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + NODE -> Value.NODE + PYTHON -> Value.PYTHON + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - NODE -> Known.NODE - PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) - } + fun known(): Known = when (this) { + NODE -> Known.NODE + PYTHON -> Known.PYTHON + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2378,37 +2325,33 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - INLINE -> Value.INLINE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + INLINE -> Value.INLINE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - INLINE -> Known.INLINE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + INLINE -> Known.INLINE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2431,17 +2374,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CODE -> Value.CODE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + CODE -> Value.CODE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - CODE -> Known.CODE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + CODE -> Known.CODE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2449,12 +2390,7 @@ constructor( @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect - class Global - private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { + class Global private constructor(private val type: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2464,9 +2400,13 @@ constructor( fun name(): String = name.getRequired("name") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing @@ -2474,39 +2414,37 @@ constructor( fun validate(): Global = apply { if (!validated) { - type() - name() - validated = true + type() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -2529,13 +2467,17 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2547,33 +2489,29 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Global = - Global( - type, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Global = Global( + type, + name, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2596,37 +2534,33 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionType && this.value == other.value + return other is FunctionType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2657,48 +2591,49 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TASK -> Value.TASK - LLM -> Value.LLM - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + TASK -> Value.TASK + LLM -> Value.LLM + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - TASK -> Known.TASK - LLM -> Known.LLM - SCORER -> Known.SCORER - else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") - } + fun known(): Known = when (this) { + TASK -> Known.TASK + LLM -> Known.LLM + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin - private constructor( - private val objectType: ObjectType?, - private val objectId: String?, - private val internal_: Boolean?, - private val additionalProperties: Map, + class Origin private constructor( + private val objectType: ObjectType?, + private val objectId: String?, + private val internal_: Boolean?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + fun objectType(): ObjectType? = objectType /** Id of the object the function is originating from */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") + fun objectId(): String? = objectId /** - * 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") fun internal_(): Boolean? = internal_ + @JsonProperty("internal") + fun internal_(): Boolean? = internal_ @JsonAnyGetter @ExcludeMissing @@ -2707,32 +2642,30 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.internal_ == other.internal_ && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.internal_ == other.internal_ && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - internal_, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + objectType, + objectId, + internal_, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" companion object { @@ -2755,18 +2688,24 @@ constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { + this.objectType = objectType + } /** Id of the object the function is originating from */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { + this.objectId = objectId + } /** - * 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") - fun internal_(internal_: Boolean) = apply { this.internal_ = internal_ } + fun internal_(internal_: Boolean) = apply { + this.internal_ = internal_ + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2782,29 +2721,28 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Origin = - Origin( - objectType, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - internal_, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = Origin( + objectType, + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + internal_, + additionalProperties.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2867,37 +2805,35 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt index d766ee5e..f18c2f0a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class FunctionDeleteParams -constructor( - private val functionId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class FunctionDeleteParams constructor( + private val functionId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun functionId(): String = functionId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionDeleteParams && - this.functionId == other.functionId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is FunctionDeleteParams && + this.functionId == other.functionId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - functionId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + functionId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "FunctionDeleteParams{functionId=$functionId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "FunctionDeleteParams{functionId=$functionId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** Function id */ - fun functionId(functionId: String) = apply { this.functionId = functionId } + fun functionId(functionId: String) = apply { + this.functionId = functionId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): FunctionDeleteParams = - FunctionDeleteParams( - checkNotNull(functionId) { "`functionId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): FunctionDeleteParams = FunctionDeleteParams( + checkNotNull(functionId) { + "`functionId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt index 6e4e3bd9..c87225cb 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPage.kt @@ -2,97 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Function import com.braintrustdata.api.services.blocking.FunctionService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class FunctionListPage -private constructor( - private val functionService: FunctionService, - private val params: FunctionListParams, - private val response: Response, -) { +class FunctionListPage private constructor(private val functionService: FunctionService, private val params: FunctionListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionListPage && - this.functionService == other.functionService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is FunctionListPage && + this.functionService == other.functionService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - functionService, - params, - response, - ) + return Objects.hash( + functionService, + params, + response, + ) } - override fun toString() = - "FunctionListPage{functionService=$functionService, params=$params, response=$response}" + override fun toString() = "FunctionListPage{functionService=$functionService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): FunctionListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): FunctionListPage? { - return getNextPageParams()?.let { functionService.list(it) } + return getNextPageParams()?.let { + functionService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(functionService: FunctionService, params: FunctionListParams, response: Response) = - FunctionListPage( - functionService, - params, - response, - ) + fun of(functionService: FunctionService, params: FunctionListParams, response: Response) = FunctionListPage( + functionService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -100,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "FunctionListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -153,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: FunctionListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: FunctionListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt index cc3cfdc5..b4e32c19 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListPageAsync.kt @@ -2,103 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.FunctionServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Function +import com.braintrustdata.api.services.async.FunctionServiceAsync -class FunctionListPageAsync -private constructor( - private val functionService: FunctionServiceAsync, - private val params: FunctionListParams, - private val response: Response, -) { +class FunctionListPageAsync private constructor(private val functionService: FunctionServiceAsync, private val params: FunctionListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionListPageAsync && - this.functionService == other.functionService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is FunctionListPageAsync && + this.functionService == other.functionService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - functionService, - params, - response, - ) + return Objects.hash( + functionService, + params, + response, + ) } - override fun toString() = - "FunctionListPageAsync{functionService=$functionService, params=$params, response=$response}" + override fun toString() = "FunctionListPageAsync{functionService=$functionService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): FunctionListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + FunctionListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + FunctionListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): FunctionListPageAsync? { - return getNextPageParams()?.let { functionService.list(it) } + return getNextPageParams()?.let { + functionService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - functionService: FunctionServiceAsync, - params: FunctionListParams, - response: Response - ) = - FunctionListPageAsync( - functionService, - params, - response, - ) + fun of(functionService: FunctionServiceAsync, params: FunctionListParams, response: Response) = FunctionListPageAsync( + functionService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -106,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "FunctionListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -159,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: FunctionListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: FunctionListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt index e2e38028..82994022 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionListParams.kt @@ -2,37 +2,54 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class FunctionListParams constructor( + private val endingBefore: String?, + private val functionName: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectId: String?, + private val projectName: String?, + private val slug: String?, + private val startingAfter: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class FunctionListParams -constructor( - private val endingBefore: String?, - private val functionName: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectId: String?, - private val projectName: String?, - private val slug: String?, - private val startingAfter: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun endingBefore(): String? = endingBefore @@ -56,19 +73,39 @@ constructor( fun version(): String? = version internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.functionName?.let { params.put("function_name", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.slug?.let { params.put("slug", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - this.version?.let { params.put("version", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.functionName?.let { + params.put("function_name", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.projectId?.let { + params.put("project_id", listOf(it.toString())) + } + this.projectName?.let { + params.put("project_name", listOf(it.toString())) + } + this.slug?.let { + params.put("slug", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + this.version?.let { + params.put("version", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -78,44 +115,43 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionListParams && - this.endingBefore == other.endingBefore && - this.functionName == other.functionName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.slug == other.slug && - this.startingAfter == other.startingAfter && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is FunctionListParams && + this.endingBefore == other.endingBefore && + this.functionName == other.functionName && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectId == other.projectId && + this.projectName == other.projectName && + this.slug == other.slug && + this.startingAfter == other.startingAfter && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - functionName, - ids, - limit, - orgName, - projectId, - projectName, - slug, - startingAfter, - version, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + endingBefore, + functionName, + ids, + limit, + orgName, + projectId, + projectName, + slug, + startingAfter, + version, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "FunctionListParams{endingBefore=$endingBefore, functionName=$functionName, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -158,64 +194,88 @@ 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 + } /** Name of the function to search for */ - fun functionName(functionName: String) = apply { this.functionName = functionName } + fun functionName(functionName: String) = apply { + this.functionName = 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(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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: String) = apply { + this.projectName = projectName + } /** Retrieve prompt with a specific slug */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: String) = apply { + this.slug = slug + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } /** * 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -255,86 +315,81 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): FunctionListParams = - FunctionListParams( - endingBefore, - functionName, - ids, - limit, - orgName, - projectId, - projectName, - slug, - startingAfter, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): FunctionListParams = FunctionListParams( + endingBefore, + functionName, + ids, + limit, + orgName, + projectId, + projectName, + slug, + startingAfter, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -351,38 +406,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt index c0260ada..91502008 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionReplaceParams.kt @@ -2,45 +2,54 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class FunctionReplaceParams constructor( + private val functionData: FunctionData, + private val name: String, + private val projectId: String, + private val slug: String, + private val description: String?, + private val functionType: FunctionType?, + private val origin: Origin?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class FunctionReplaceParams -constructor( - private val functionData: FunctionData, - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val functionType: FunctionType?, - private val origin: Origin?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun functionData(): FunctionData = functionData @@ -62,18 +71,18 @@ constructor( fun tags(): List? = tags internal fun getBody(): FunctionReplaceBody { - return FunctionReplaceBody( - functionData, - name, - projectId, - slug, - description, - functionType, - origin, - promptData, - tags, - additionalBodyProperties, - ) + return FunctionReplaceBody( + functionData, + name, + projectId, + slug, + description, + functionType, + origin, + promptData, + tags, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -82,45 +91,54 @@ constructor( @JsonDeserialize(builder = FunctionReplaceBody.Builder::class) @NoAutoDetect - class FunctionReplaceBody - internal constructor( - private val functionData: FunctionData?, - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val functionType: FunctionType?, - private val origin: Origin?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, + class FunctionReplaceBody internal constructor( + private val functionData: FunctionData?, + private val name: String?, + private val projectId: String?, + private val slug: String?, + private val description: String?, + private val functionType: FunctionType?, + private val origin: Origin?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 - @JsonProperty("function_data") fun functionData(): FunctionData? = functionData + @JsonProperty("function_data") + fun functionData(): FunctionData? = functionData /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") + fun projectId(): String? = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(): String? = slug + @JsonProperty("slug") + fun slug(): String? = slug /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description - @JsonProperty("function_type") fun functionType(): FunctionType? = functionType + @JsonProperty("function_type") + fun functionType(): FunctionType? = functionType - @JsonProperty("origin") fun origin(): Origin? = origin + @JsonProperty("origin") + fun origin(): Origin? = origin /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") + fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -129,44 +147,42 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionReplaceBody && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.origin == other.origin && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FunctionReplaceBody && + this.functionData == other.functionData && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.functionType == other.functionType && + this.origin == other.origin && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - functionData, - name, - projectId, - slug, - description, - functionType, - origin, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + functionData, + name, + projectId, + slug, + description, + functionType, + origin, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionReplaceBody{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { @@ -205,32 +221,50 @@ constructor( } /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } + @JsonProperty("slug") + fun slug(slug: String) = apply { + this.slug = slug + } /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } @JsonProperty("function_type") fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } - @JsonProperty("origin") fun origin(origin: Origin) = apply { this.origin = origin } + @JsonProperty("origin") + fun origin(origin: Origin) = apply { + this.origin = origin + } /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + @JsonProperty("tags") + fun tags(tags: List) = apply { + this.tags = tags + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -246,19 +280,26 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionReplaceBody = - FunctionReplaceBody( - checkNotNull(functionData) { "`functionData` is required but was not set" }, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionType, - origin, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionReplaceBody = FunctionReplaceBody( + checkNotNull(functionData) { + "`functionData` is required but was not set" + }, + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + checkNotNull(slug) { + "`slug` is required but was not set" + }, + description, + functionType, + origin, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -269,44 +310,43 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionReplaceParams && - this.functionData == other.functionData && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.origin == other.origin && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is FunctionReplaceParams && + this.functionData == other.functionData && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.functionType == other.functionType && + this.origin == other.origin && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - functionData, - name, - projectId, - slug, - description, - functionType, - origin, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + functionData, + name, + projectId, + slug, + description, + functionType, + origin, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "FunctionReplaceParams{functionData=$functionData, name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, origin=$origin, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -346,7 +386,9 @@ constructor( additionalBodyProperties(functionReplaceParams.additionalBodyProperties) } - fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } + fun functionData(functionData: FunctionData) = apply { + this.functionData = functionData + } fun functionData(prompt: FunctionData.Prompt) = apply { this.functionData = FunctionData.ofPrompt(prompt) @@ -361,23 +403,37 @@ constructor( } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: String) = apply { + this.slug = slug + } /** Textual description of the prompt */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } - fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } + fun functionType(functionType: FunctionType) = apply { + this.functionType = functionType + } - fun origin(origin: Origin) = apply { this.origin = origin } + fun origin(origin: Origin) = apply { + this.origin = origin + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -386,7 +442,9 @@ constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun addTag(tag: String) = apply { + this.tags.add(tag) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -426,7 +484,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -437,108 +497,108 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): FunctionReplaceParams = - FunctionReplaceParams( - checkNotNull(functionData) { "`functionData` is required but was not set" }, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionType, - origin, - promptData, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): FunctionReplaceParams = FunctionReplaceParams( + checkNotNull(functionData) { + "`functionData` is required but was not set" + }, + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + checkNotNull(slug) { + "`slug` is required but was not set" + }, + description, + functionType, + origin, + promptData, + if(tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - class FunctionData - private constructor( - private val prompt: Prompt? = null, - private val code: Code? = null, - private val global: Global? = null, - private val _json: JsonValue? = null, + class FunctionData private constructor( + private val prompt: Prompt? = null, + private val code: Code? = null, + private val global: Global? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun prompt(): Prompt? = prompt - fun code(): Code? = code - fun global(): Global? = global fun isPrompt(): Boolean = prompt != null - fun isCode(): Boolean = code != null - fun isGlobal(): Boolean = global != null fun asPrompt(): Prompt = prompt.getOrThrow("prompt") - fun asCode(): Code = code.getOrThrow("code") - fun asGlobal(): Global = global.getOrThrow("global") fun _json(): JsonValue? = _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) + } } fun validate(): FunctionData = apply { if (!validated) { - if (prompt == null && code == null && global == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - prompt?.validate() - code?.validate() - global?.validate() - validated = true + if (prompt == null && code == null && global == null) { + throw BraintrustInvalidDataException("Unknown FunctionData: $_json") + } + prompt?.validate() + code?.validate() + global?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionData && - this.prompt == other.prompt && - this.code == other.code && - this.global == other.global + if (this === other) { + return true + } + + return other is FunctionData && + this.prompt == other.prompt && + this.code == other.code && + this.global == other.global } override fun hashCode(): Int { - return Objects.hash( - prompt, - code, - global, - ) + return Objects.hash( + prompt, + code, + global, + ) } override fun toString(): String { - return when { - prompt != null -> "FunctionData{prompt=$prompt}" - code != null -> "FunctionData{code=$code}" - global != null -> "FunctionData{global=$global}" - _json != null -> "FunctionData{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionData") - } + return when { + prompt != null -> "FunctionData{prompt=$prompt}" + code != null -> "FunctionData{code=$code}" + global != null -> "FunctionData{global=$global}" + _json != null -> "FunctionData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionData") + } } companion object { @@ -559,55 +619,44 @@ constructor( fun visitGlobal(global: Global): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } 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) } } 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") + } } } @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect - class Prompt - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { + class Prompt private constructor(private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -615,7 +664,9 @@ constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -623,32 +674,31 @@ constructor( fun validate(): Prompt = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Prompt && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Prompt && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" companion object { @@ -669,7 +719,9 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -681,28 +733,25 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -725,17 +774,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - PROMPT -> Value.PROMPT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + PROMPT -> Value.PROMPT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - PROMPT -> Known.PROMPT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + PROMPT -> Known.PROMPT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -743,12 +790,7 @@ constructor( @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect - class Code - private constructor( - private val type: JsonField, - private val data: JsonField, - private val additionalProperties: Map, - ) { + class Code private constructor(private val type: JsonField, private val data: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -758,9 +800,13 @@ constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") + @ExcludeMissing + fun _data() = data @JsonAnyGetter @ExcludeMissing @@ -768,39 +814,37 @@ constructor( fun validate(): Code = apply { if (!validated) { - type() - data() - validated = true + type() + data() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Code && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Code && + this.type == other.type && + this.data == other.data && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + data, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" + override fun toString() = "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" companion object { @@ -823,13 +867,17 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun data(data: Data) = data(JsonField.of(data)) @JsonProperty("data") @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = apply { + this.data = data + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -841,84 +889,74 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Code = - Code( - type, - data, - additionalProperties.toUnmodifiable(), - ) + fun build(): Code = Code( + type, + data, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( - private val bundle: Bundle? = null, - private val inline: Inline? = null, - private val _json: JsonValue? = null, - ) { + class Data private constructor(private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun bundle(): Bundle? = bundle - fun inline(): Inline? = inline fun isBundle(): Boolean = bundle != null - fun isInline(): Boolean = inline != null fun asBundle(): Bundle = bundle.getOrThrow("bundle") - fun asInline(): Inline = inline.getOrThrow("inline") fun _json(): JsonValue? = _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) + } } fun validate(): Data = apply { if (!validated) { - if (bundle == null && inline == null) { - throw BraintrustInvalidDataException("Unknown Data: $_json") - } - bundle?.validate() - inline?.validate() - validated = true + if (bundle == null && inline == null) { + throw BraintrustInvalidDataException("Unknown Data: $_json") + } + bundle?.validate() + inline?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Data && - this.bundle == other.bundle && - this.inline == other.inline + return other is Data && + this.bundle == other.bundle && + this.inline == other.inline } override fun hashCode(): Int { - return Objects.hash(bundle, inline) + return Objects.hash(bundle, inline) } override fun toString(): String { - return when { - bundle != null -> "Data{bundle=$bundle}" - inline != null -> "Data{inline=$inline}" - _json != null -> "Data{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Data") - } + return when { + bundle != null -> "Data{bundle=$bundle}" + inline != null -> "Data{inline=$inline}" + _json != null -> "Data{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Data") + } } companion object { @@ -935,53 +973,47 @@ constructor( fun visitInline(inline: Inline): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - 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) - } - - return Data(_json = json) + 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) + } + + return Data(_json = json) } } 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") + } } } @JsonDeserialize(builder = Bundle.Builder::class) @NoAutoDetect - class Bundle - private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val preview: JsonField, - private val additionalProperties: Map, + class Bundle private constructor( + private val type: JsonField, + private val runtimeContext: JsonField, + private val location: JsonField, + private val bundleId: JsonField, + private val preview: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -990,8 +1022,7 @@ constructor( fun type(): Type = type.getRequired("type") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun location(): Location = location.getRequired("location") @@ -1000,18 +1031,26 @@ constructor( /** A preview of the code */ fun preview(): String? = preview.getNullable("preview") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") + @ExcludeMissing + fun _location() = location - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + @JsonProperty("bundle_id") + @ExcludeMissing + fun _bundleId() = bundleId /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview() = preview + @JsonProperty("preview") + @ExcludeMissing + fun _preview() = preview @JsonAnyGetter @ExcludeMissing @@ -1019,48 +1058,46 @@ constructor( fun validate(): Bundle = apply { if (!validated) { - type() - runtimeContext().validate() - location().validate() - bundleId() - preview() - validated = true + type() + runtimeContext().validate() + location().validate() + bundleId() + preview() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Bundle && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.preview == other.preview && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Bundle && + this.type == other.type && + this.runtimeContext == other.runtimeContext && + this.location == other.location && + this.bundleId == other.bundleId && + this.preview == other.preview && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - location, - bundleId, - preview, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + runtimeContext, + location, + bundleId, + preview, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Bundle{type=$type, runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{type=$type, runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" companion object { @@ -1074,8 +1111,7 @@ constructor( private var location: JsonField = JsonMissing.of() private var bundleId: JsonField = JsonMissing.of() private var preview: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bundle: Bundle) = apply { this.type = bundle.type @@ -1090,10 +1126,11 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -1123,42 +1160,42 @@ constructor( /** A preview of the code */ @JsonProperty("preview") @ExcludeMissing - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = apply { + this.preview = preview + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Bundle = - Bundle( - type, - runtimeContext, - location, - bundleId, - preview, - additionalProperties.toUnmodifiable(), - ) + fun build(): Bundle = Bundle( + type, + runtimeContext, + location, + bundleId, + preview, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Location.Builder::class) @NoAutoDetect - class Location - private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + class Location private constructor( + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1171,11 +1208,17 @@ constructor( fun position(): Position = position.getRequired("position") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + @JsonProperty("eval_name") + @ExcludeMissing + fun _evalName() = evalName - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("position") + @ExcludeMissing + fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -1183,42 +1226,40 @@ constructor( fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() - validated = true + type() + evalName() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Location && + this.type == other.type && + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + evalName, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" companion object { @@ -1230,8 +1271,7 @@ constructor( private var type: JsonField = JsonMissing.of() private var evalName: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(location: Location) = apply { this.type = location.type @@ -1244,7 +1284,9 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) @@ -1262,97 +1304,85 @@ constructor( this.position = position } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Location = - Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Location = Location( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position - private constructor( - private val type: Type? = null, - private val scorer: Scorer? = null, - private val _json: JsonValue? = null, - ) { + class Position private constructor(private val type: Type? = null, private val scorer: Scorer? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun type(): Type? = type - fun scorer(): Scorer? = scorer fun isType(): Boolean = type != null - fun isScorer(): Boolean = scorer != null fun asType(): Type = type.getOrThrow("type") - fun asScorer(): Scorer = scorer.getOrThrow("scorer") fun _json(): JsonValue? = _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) + } } fun validate(): Position = apply { if (!validated) { - if (type == null && scorer == null) { - throw BraintrustInvalidDataException( - "Unknown Position: $_json" - ) - } - type?.validate() - scorer?.validate() - validated = true + if (type == null && scorer == null) { + throw BraintrustInvalidDataException("Unknown Position: $_json") + } + type?.validate() + scorer?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Position && - this.type == other.type && - this.scorer == other.scorer + return other is Position && + this.type == other.type && + this.scorer == other.scorer } override fun hashCode(): Int { - return Objects.hash(type, scorer) + return Objects.hash(type, scorer) } override fun toString(): String { - return when { - type != null -> "Position{type=$type}" - scorer != null -> "Position{scorer=$scorer}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") - } + return when { + type != null -> "Position{type=$type}" + scorer != null -> "Position{scorer=$scorer}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } } companion object { @@ -1369,50 +1399,40 @@ constructor( fun visitScorer(scorer: Scorer): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - 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) - } - - return Position(_json = json) + 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) + } + + return Position(_json = json) } } 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") + } } } @JsonDeserialize(builder = Type.Builder::class) @NoAutoDetect - class Type - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { + class Type private constructor(private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1420,41 +1440,41 @@ constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Type = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Type && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1464,9 +1484,7 @@ constructor( class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(type: Type) = apply { this.type = type.type @@ -1477,46 +1495,39 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Type = - Type(type, additionalProperties.toUnmodifiable()) + fun build(): Type = Type(type, additionalProperties.toUnmodifiable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1539,20 +1550,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } + fun value(): Value = when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + TASK -> Known.TASK + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1560,12 +1566,7 @@ constructor( @JsonDeserialize(builder = Scorer.Builder::class) @NoAutoDetect - class Scorer - private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, - ) { + class Scorer private constructor(private val type: JsonField, private val index: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1575,50 +1576,51 @@ constructor( fun index(): Double = index.getRequired("index") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("index") @ExcludeMissing fun _index() = index + @JsonProperty("index") + @ExcludeMissing + fun _index() = index @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Scorer = apply { if (!validated) { - type() - index() - validated = true + type() + index() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scorer && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Scorer && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + index, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + override fun toString() = "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" companion object { @@ -1629,9 +1631,7 @@ constructor( private var type: JsonField = JsonMissing.of() private var index: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(scorer: Scorer) = apply { this.type = scorer.type @@ -1643,7 +1643,9 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun index(index: Double) = index(JsonField.of(index)) @@ -1653,48 +1655,39 @@ constructor( this.index = index } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Scorer = - Scorer( - type, - index, - additionalProperties.toUnmodifiable(), - ) + fun build(): Scorer = Scorer( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1717,41 +1710,33 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SCORER -> Known.SCORER - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } + fun value(): Value = when (this) { + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1774,18 +1759,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + EXPERIMENT -> Value.EXPERIMENT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + EXPERIMENT -> Known.EXPERIMENT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1793,12 +1775,7 @@ constructor( @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext - private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, - ) { + class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1808,9 +1785,13 @@ constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime() = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -1818,39 +1799,37 @@ constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -1861,8 +1840,7 @@ constructor( private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(runtimeContext: RuntimeContext) = apply { this.runtime = runtimeContext.runtime @@ -1886,44 +1864,39 @@ constructor( this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): RuntimeContext = - RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && this.value == other.value + return other is Runtime && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1950,42 +1923,34 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - NODE -> Value.NODE - PYTHON -> Value.PYTHON - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + NODE -> Value.NODE + PYTHON -> Value.PYTHON + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - NODE -> Known.NODE - PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) - } + fun known(): Known = when (this) { + NODE -> Known.NODE + PYTHON -> Known.PYTHON + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2008,17 +1973,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - BUNDLE -> Value.BUNDLE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + BUNDLE -> Value.BUNDLE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - BUNDLE -> Known.BUNDLE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + BUNDLE -> Known.BUNDLE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2026,12 +1989,12 @@ constructor( @JsonDeserialize(builder = Inline.Builder::class) @NoAutoDetect - class Inline - private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val code: JsonField, - private val additionalProperties: Map, + class Inline private constructor( + private val type: JsonField, + private val runtimeContext: JsonField, + private val code: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2040,18 +2003,21 @@ constructor( fun type(): Type = type.getRequired("type") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun code(): String = code.getRequired("code") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") + @ExcludeMissing + fun _code() = code @JsonAnyGetter @ExcludeMissing @@ -2059,42 +2025,40 @@ constructor( fun validate(): Inline = apply { if (!validated) { - type() - runtimeContext().validate() - code() - validated = true + type() + runtimeContext().validate() + code() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Inline && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.code == other.code && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Inline && + this.type == other.type && + this.runtimeContext == other.runtimeContext && + this.code == other.code && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - code, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + runtimeContext, + code, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" companion object { @@ -2106,8 +2070,7 @@ constructor( private var type: JsonField = JsonMissing.of() private var runtimeContext: JsonField = JsonMissing.of() private var code: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(inline: Inline) = apply { this.type = inline.type @@ -2120,10 +2083,11 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -2135,40 +2099,35 @@ constructor( @JsonProperty("code") @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = apply { + this.code = code + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Inline = - Inline( - type, - runtimeContext, - code, - additionalProperties.toUnmodifiable(), - ) + fun build(): Inline = Inline( + type, + runtimeContext, + code, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext - private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, - ) { + class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2178,9 +2137,13 @@ constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime() = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -2188,39 +2151,37 @@ constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -2231,8 +2192,7 @@ constructor( private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(runtimeContext: RuntimeContext) = apply { this.runtime = runtimeContext.runtime @@ -2256,44 +2216,39 @@ constructor( this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): RuntimeContext = - RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && this.value == other.value + return other is Runtime && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2320,42 +2275,34 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - NODE -> Value.NODE - PYTHON -> Value.PYTHON - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + NODE -> Value.NODE + PYTHON -> Value.PYTHON + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - NODE -> Known.NODE - PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) - } + fun known(): Known = when (this) { + NODE -> Known.NODE + PYTHON -> Known.PYTHON + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2378,37 +2325,33 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - INLINE -> Value.INLINE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + INLINE -> Value.INLINE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - INLINE -> Known.INLINE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + INLINE -> Known.INLINE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2431,17 +2374,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CODE -> Value.CODE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + CODE -> Value.CODE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - CODE -> Known.CODE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + CODE -> Known.CODE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2449,12 +2390,7 @@ constructor( @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect - class Global - private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { + class Global private constructor(private val type: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2464,9 +2400,13 @@ constructor( fun name(): String = name.getRequired("name") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing @@ -2474,39 +2414,37 @@ constructor( fun validate(): Global = apply { if (!validated) { - type() - name() - validated = true + type() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -2529,13 +2467,17 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2547,33 +2489,29 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Global = - Global( - type, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Global = Global( + type, + name, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2596,37 +2534,33 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionType && this.value == other.value + return other is FunctionType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2657,48 +2591,49 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TASK -> Value.TASK - LLM -> Value.LLM - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + TASK -> Value.TASK + LLM -> Value.LLM + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - TASK -> Known.TASK - LLM -> Known.LLM - SCORER -> Known.SCORER - else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") - } + fun known(): Known = when (this) { + TASK -> Known.TASK + LLM -> Known.LLM + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin - private constructor( - private val objectType: ObjectType?, - private val objectId: String?, - private val internal_: Boolean?, - private val additionalProperties: Map, + class Origin private constructor( + private val objectType: ObjectType?, + private val objectId: String?, + private val internal_: Boolean?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + fun objectType(): ObjectType? = objectType /** Id of the object the function is originating from */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") + fun objectId(): String? = objectId /** - * 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") fun internal_(): Boolean? = internal_ + @JsonProperty("internal") + fun internal_(): Boolean? = internal_ @JsonAnyGetter @ExcludeMissing @@ -2707,32 +2642,30 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.internal_ == other.internal_ && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.internal_ == other.internal_ && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - internal_, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + objectType, + objectId, + internal_, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{objectType=$objectType, objectId=$objectId, internal_=$internal_, additionalProperties=$additionalProperties}" companion object { @@ -2755,18 +2688,24 @@ constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { + this.objectType = objectType + } /** Id of the object the function is originating from */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { + this.objectId = objectId + } /** - * 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") - fun internal_(internal_: Boolean) = apply { this.internal_ = internal_ } + fun internal_(internal_: Boolean) = apply { + this.internal_ = internal_ + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2782,29 +2721,28 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Origin = - Origin( - objectType, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - internal_, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = Origin( + objectType, + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + internal_, + additionalProperties.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2867,37 +2805,35 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt index cd7aba68..dc91a874 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class FunctionRetrieveParams -constructor( - private val functionId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class FunctionRetrieveParams constructor(private val functionId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun functionId(): String = functionId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionRetrieveParams && - this.functionId == other.functionId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is FunctionRetrieveParams && + this.functionId == other.functionId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - functionId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + functionId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "FunctionRetrieveParams{functionId=$functionId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "FunctionRetrieveParams{functionId=$functionId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** Function id */ - fun functionId(functionId: String) = apply { this.functionId = functionId } + fun functionId(functionId: String) = apply { + this.functionId = functionId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): FunctionRetrieveParams = - FunctionRetrieveParams( - checkNotNull(functionId) { "`functionId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): FunctionRetrieveParams = FunctionRetrieveParams( + checkNotNull(functionId) { + "`functionId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt index 815861df..10e96512 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/FunctionUpdateParams.kt @@ -2,42 +2,51 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class FunctionUpdateParams constructor( + private val functionId: String, + private val description: String?, + private val functionData: FunctionData?, + private val name: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class FunctionUpdateParams -constructor( - private val functionId: String, - private val description: String?, - private val functionData: FunctionData?, - private val name: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun functionId(): String = functionId @@ -53,14 +62,14 @@ constructor( fun tags(): List? = tags internal fun getBody(): FunctionUpdateBody { - return FunctionUpdateBody( - description, - functionData, - name, - promptData, - tags, - additionalBodyProperties, - ) + return FunctionUpdateBody( + description, + functionData, + name, + promptData, + tags, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -68,39 +77,44 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> functionId - else -> "" - } + return when (index) { + 0 -> functionId + else -> "" + } } @JsonDeserialize(builder = FunctionUpdateBody.Builder::class) @NoAutoDetect - class FunctionUpdateBody - internal constructor( - private val description: String?, - private val functionData: FunctionData?, - private val name: String?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, + class FunctionUpdateBody internal constructor( + private val description: String?, + private val functionData: FunctionData?, + private val name: String?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description - @JsonProperty("function_data") fun functionData(): FunctionData? = functionData + @JsonProperty("function_data") + fun functionData(): FunctionData? = functionData /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") + fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -109,36 +123,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionUpdateBody && - this.description == other.description && - this.functionData == other.functionData && - this.name == other.name && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is FunctionUpdateBody && + this.description == other.description && + this.functionData == other.functionData && + this.name == other.name && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - description, - functionData, - name, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + description, + functionData, + name, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionUpdateBody{description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { @@ -165,7 +177,9 @@ constructor( /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } @JsonProperty("function_data") fun functionData(functionData: FunctionData) = apply { @@ -173,14 +187,22 @@ constructor( } /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + @JsonProperty("tags") + fun tags(tags: List) = apply { + this.tags = tags + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -196,15 +218,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): FunctionUpdateBody = - FunctionUpdateBody( - description, - functionData, - name, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionUpdateBody = FunctionUpdateBody( + description, + functionData, + name, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -215,38 +236,37 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionUpdateParams && - this.functionId == other.functionId && - this.description == other.description && - this.functionData == other.functionData && - this.name == other.name && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is FunctionUpdateParams && + this.functionId == other.functionId && + this.description == other.description && + this.functionData == other.functionData && + this.name == other.name && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - functionId, - description, - functionData, - name, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + functionId, + description, + functionData, + name, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "FunctionUpdateParams{functionId=$functionId, description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "FunctionUpdateParams{functionId=$functionId, description=$description, functionData=$functionData, name=$name, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -281,12 +301,18 @@ constructor( } /** 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 { this.description = description } + fun description(description: String) = apply { + this.description = description + } - fun functionData(functionData: FunctionData) = apply { this.functionData = functionData } + fun functionData(functionData: FunctionData) = apply { + this.functionData = functionData + } fun functionData(prompt: FunctionData.Prompt) = apply { this.functionData = FunctionData.ofPrompt(prompt) @@ -305,10 +331,14 @@ constructor( } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -317,7 +347,9 @@ constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun addTag(tag: String) = apply { + this.tags.add(tag) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -357,7 +389,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -368,117 +402,108 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): FunctionUpdateParams = - FunctionUpdateParams( - checkNotNull(functionId) { "`functionId` is required but was not set" }, - description, - functionData, - name, - promptData, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): FunctionUpdateParams = FunctionUpdateParams( + checkNotNull(functionId) { + "`functionId` is required but was not set" + }, + description, + functionData, + name, + promptData, + if(tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionData.Deserializer::class) @JsonSerialize(using = FunctionData.Serializer::class) - 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, + 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, + ) { private var validated: Boolean = false fun prompt(): Prompt? = prompt - fun code(): Code? = code - fun global(): Global? = global - fun nullableVariant(): NullableVariant? = nullableVariant fun isPrompt(): Boolean = prompt != null - fun isCode(): Boolean = code != null - fun isGlobal(): Boolean = global != null - fun isNullableVariant(): Boolean = nullableVariant != null fun asPrompt(): Prompt = prompt.getOrThrow("prompt") - fun asCode(): Code = code.getOrThrow("code") - fun asGlobal(): Global = global.getOrThrow("global") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): JsonValue? = _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) + } } fun validate(): FunctionData = apply { if (!validated) { - if (prompt == null && code == null && global == null && nullableVariant == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - prompt?.validate() - code?.validate() - global?.validate() - nullableVariant?.validate() - validated = true + if (prompt == null && code == null && global == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown FunctionData: $_json") + } + prompt?.validate() + code?.validate() + global?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionData && - this.prompt == other.prompt && - this.code == other.code && - this.global == other.global && - this.nullableVariant == other.nullableVariant + if (this === other) { + return true + } + + return other is FunctionData && + this.prompt == other.prompt && + this.code == other.code && + this.global == other.global && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - prompt, - code, - global, - nullableVariant, - ) + return Objects.hash( + prompt, + code, + global, + nullableVariant, + ) } override fun toString(): String { - return when { - prompt != null -> "FunctionData{prompt=$prompt}" - code != null -> "FunctionData{code=$code}" - global != null -> "FunctionData{global=$global}" - nullableVariant != null -> "FunctionData{nullableVariant=$nullableVariant}" - _json != null -> "FunctionData{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionData") - } + return when { + prompt != null -> "FunctionData{prompt=$prompt}" + code != null -> "FunctionData{code=$code}" + global != null -> "FunctionData{global=$global}" + nullableVariant != null -> "FunctionData{nullableVariant=$nullableVariant}" + _json != null -> "FunctionData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionData") + } } companion object { @@ -489,8 +514,7 @@ constructor( fun ofGlobal(global: Global) = FunctionData(global = global) - fun ofNullableVariant(nullableVariant: NullableVariant) = - FunctionData(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = FunctionData(nullableVariant = nullableVariant) } interface Visitor { @@ -504,60 +528,48 @@ constructor( fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") + throw BraintrustInvalidDataException("Unknown FunctionData: $json") } } 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) } } 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") + } } } @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect - class Prompt - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { + class Prompt private constructor(private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -565,7 +577,9 @@ constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -573,32 +587,31 @@ constructor( fun validate(): Prompt = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Prompt && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Prompt && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{type=$type, additionalProperties=$additionalProperties}" companion object { @@ -619,7 +632,9 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -631,28 +646,25 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -675,17 +687,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - PROMPT -> Value.PROMPT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + PROMPT -> Value.PROMPT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - PROMPT -> Known.PROMPT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + PROMPT -> Known.PROMPT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -693,12 +703,7 @@ constructor( @JsonDeserialize(builder = Code.Builder::class) @NoAutoDetect - class Code - private constructor( - private val type: JsonField, - private val data: JsonField, - private val additionalProperties: Map, - ) { + class Code private constructor(private val type: JsonField, private val data: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -708,9 +713,13 @@ constructor( fun data(): Data = data.getRequired("data") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") + @ExcludeMissing + fun _data() = data @JsonAnyGetter @ExcludeMissing @@ -718,39 +727,37 @@ constructor( fun validate(): Code = apply { if (!validated) { - type() - data() - validated = true + type() + data() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Code && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Code && + this.type == other.type && + this.data == other.data && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + data, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" + override fun toString() = "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" companion object { @@ -773,13 +780,17 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun data(data: Data) = data(JsonField.of(data)) @JsonProperty("data") @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } + fun data(data: JsonField) = apply { + this.data = data + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -791,84 +802,74 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Code = - Code( - type, - data, - additionalProperties.toUnmodifiable(), - ) + fun build(): Code = Code( + type, + data, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Data.Deserializer::class) @JsonSerialize(using = Data.Serializer::class) - class Data - private constructor( - private val bundle: Bundle? = null, - private val inline: Inline? = null, - private val _json: JsonValue? = null, - ) { + class Data private constructor(private val bundle: Bundle? = null, private val inline: Inline? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun bundle(): Bundle? = bundle - fun inline(): Inline? = inline fun isBundle(): Boolean = bundle != null - fun isInline(): Boolean = inline != null fun asBundle(): Bundle = bundle.getOrThrow("bundle") - fun asInline(): Inline = inline.getOrThrow("inline") fun _json(): JsonValue? = _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) + } } fun validate(): Data = apply { if (!validated) { - if (bundle == null && inline == null) { - throw BraintrustInvalidDataException("Unknown Data: $_json") - } - bundle?.validate() - inline?.validate() - validated = true + if (bundle == null && inline == null) { + throw BraintrustInvalidDataException("Unknown Data: $_json") + } + bundle?.validate() + inline?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Data && - this.bundle == other.bundle && - this.inline == other.inline + return other is Data && + this.bundle == other.bundle && + this.inline == other.inline } override fun hashCode(): Int { - return Objects.hash(bundle, inline) + return Objects.hash(bundle, inline) } override fun toString(): String { - return when { - bundle != null -> "Data{bundle=$bundle}" - inline != null -> "Data{inline=$inline}" - _json != null -> "Data{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Data") - } + return when { + bundle != null -> "Data{bundle=$bundle}" + inline != null -> "Data{inline=$inline}" + _json != null -> "Data{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Data") + } } companion object { @@ -885,53 +886,47 @@ constructor( fun visitInline(inline: Inline): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Data: $json") + throw BraintrustInvalidDataException("Unknown Data: $json") } } class Deserializer : BaseDeserializer(Data::class) { override fun ObjectCodec.deserialize(node: JsonNode): Data { - 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) - } - - return Data(_json = json) + 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) + } + + return Data(_json = json) } } 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") + } } } @JsonDeserialize(builder = Bundle.Builder::class) @NoAutoDetect - class Bundle - private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val preview: JsonField, - private val additionalProperties: Map, + class Bundle private constructor( + private val type: JsonField, + private val runtimeContext: JsonField, + private val location: JsonField, + private val bundleId: JsonField, + private val preview: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -940,8 +935,7 @@ constructor( fun type(): Type = type.getRequired("type") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun location(): Location = location.getRequired("location") @@ -950,18 +944,26 @@ constructor( /** A preview of the code */ fun preview(): String? = preview.getNullable("preview") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") + @ExcludeMissing + fun _location() = location - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId + @JsonProperty("bundle_id") + @ExcludeMissing + fun _bundleId() = bundleId /** A preview of the code */ - @JsonProperty("preview") @ExcludeMissing fun _preview() = preview + @JsonProperty("preview") + @ExcludeMissing + fun _preview() = preview @JsonAnyGetter @ExcludeMissing @@ -969,48 +971,46 @@ constructor( fun validate(): Bundle = apply { if (!validated) { - type() - runtimeContext().validate() - location().validate() - bundleId() - preview() - validated = true + type() + runtimeContext().validate() + location().validate() + bundleId() + preview() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Bundle && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.preview == other.preview && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Bundle && + this.type == other.type && + this.runtimeContext == other.runtimeContext && + this.location == other.location && + this.bundleId == other.bundleId && + this.preview == other.preview && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - location, - bundleId, - preview, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + runtimeContext, + location, + bundleId, + preview, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Bundle{type=$type, runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" + override fun toString() = "Bundle{type=$type, runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, preview=$preview, additionalProperties=$additionalProperties}" companion object { @@ -1024,8 +1024,7 @@ constructor( private var location: JsonField = JsonMissing.of() private var bundleId: JsonField = JsonMissing.of() private var preview: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bundle: Bundle) = apply { this.type = bundle.type @@ -1040,10 +1039,11 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -1073,42 +1073,42 @@ constructor( /** A preview of the code */ @JsonProperty("preview") @ExcludeMissing - fun preview(preview: JsonField) = apply { this.preview = preview } + fun preview(preview: JsonField) = apply { + this.preview = preview + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Bundle = - Bundle( - type, - runtimeContext, - location, - bundleId, - preview, - additionalProperties.toUnmodifiable(), - ) + fun build(): Bundle = Bundle( + type, + runtimeContext, + location, + bundleId, + preview, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Location.Builder::class) @NoAutoDetect - class Location - private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + class Location private constructor( + private val type: JsonField, + private val evalName: JsonField, + private val position: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1121,11 +1121,17 @@ constructor( fun position(): Position = position.getRequired("position") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName + @JsonProperty("eval_name") + @ExcludeMissing + fun _evalName() = evalName - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("position") + @ExcludeMissing + fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -1133,42 +1139,40 @@ constructor( fun validate(): Location = apply { if (!validated) { - type() - evalName() - position() - validated = true + type() + evalName() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Location && + this.type == other.type && + this.evalName == other.evalName && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + evalName, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" companion object { @@ -1180,8 +1184,7 @@ constructor( private var type: JsonField = JsonMissing.of() private var evalName: JsonField = JsonMissing.of() private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(location: Location) = apply { this.type = location.type @@ -1194,7 +1197,9 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun evalName(evalName: String) = evalName(JsonField.of(evalName)) @@ -1212,97 +1217,85 @@ constructor( this.position = position } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Location = - Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Location = Location( + type, + evalName, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Position.Deserializer::class) @JsonSerialize(using = Position.Serializer::class) - class Position - private constructor( - private val type: Type? = null, - private val scorer: Scorer? = null, - private val _json: JsonValue? = null, - ) { + class Position private constructor(private val type: Type? = null, private val scorer: Scorer? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun type(): Type? = type - fun scorer(): Scorer? = scorer fun isType(): Boolean = type != null - fun isScorer(): Boolean = scorer != null fun asType(): Type = type.getOrThrow("type") - fun asScorer(): Scorer = scorer.getOrThrow("scorer") fun _json(): JsonValue? = _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) + } } fun validate(): Position = apply { if (!validated) { - if (type == null && scorer == null) { - throw BraintrustInvalidDataException( - "Unknown Position: $_json" - ) - } - type?.validate() - scorer?.validate() - validated = true + if (type == null && scorer == null) { + throw BraintrustInvalidDataException("Unknown Position: $_json") + } + type?.validate() + scorer?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Position && - this.type == other.type && - this.scorer == other.scorer + return other is Position && + this.type == other.type && + this.scorer == other.scorer } override fun hashCode(): Int { - return Objects.hash(type, scorer) + return Objects.hash(type, scorer) } override fun toString(): String { - return when { - type != null -> "Position{type=$type}" - scorer != null -> "Position{scorer=$scorer}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") - } + return when { + type != null -> "Position{type=$type}" + scorer != null -> "Position{scorer=$scorer}" + _json != null -> "Position{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Position") + } } companion object { @@ -1319,50 +1312,40 @@ constructor( fun visitScorer(scorer: Scorer): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") + throw BraintrustInvalidDataException("Unknown Position: $json") } } class Deserializer : BaseDeserializer(Position::class) { override fun ObjectCodec.deserialize(node: JsonNode): Position { - 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) - } - - return Position(_json = json) + 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) + } + + return Position(_json = json) } } 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") + } } } @JsonDeserialize(builder = Type.Builder::class) @NoAutoDetect - class Type - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { + class Type private constructor(private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1370,41 +1353,41 @@ constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Type = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is Type && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1414,9 +1397,7 @@ constructor( class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(type: Type) = apply { this.type = type.type @@ -1427,46 +1408,39 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Type = - Type(type, additionalProperties.toUnmodifiable()) + fun build(): Type = Type(type, additionalProperties.toUnmodifiable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1489,20 +1463,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } + fun value(): Value = when (this) { + TASK -> Value.TASK + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + TASK -> Known.TASK + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1510,12 +1479,7 @@ constructor( @JsonDeserialize(builder = Scorer.Builder::class) @NoAutoDetect - class Scorer - private constructor( - private val type: JsonField, - private val index: JsonField, - private val additionalProperties: Map, - ) { + class Scorer private constructor(private val type: JsonField, private val index: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1525,50 +1489,51 @@ constructor( fun index(): Double = index.getRequired("index") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("index") @ExcludeMissing fun _index() = index + @JsonProperty("index") + @ExcludeMissing + fun _index() = index @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Scorer = apply { if (!validated) { - type() - index() - validated = true + type() + index() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scorer && - this.type == other.type && - this.index == other.index && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Scorer && + this.type == other.type && + this.index == other.index && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - index, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + index, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" + override fun toString() = "Scorer{type=$type, index=$index, additionalProperties=$additionalProperties}" companion object { @@ -1579,9 +1544,7 @@ constructor( private var type: JsonField = JsonMissing.of() private var index: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(scorer: Scorer) = apply { this.type = scorer.type @@ -1593,7 +1556,9 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun index(index: Double) = index(JsonField.of(index)) @@ -1603,48 +1568,39 @@ constructor( this.index = index } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Scorer = - Scorer( - type, - index, - additionalProperties.toUnmodifiable(), - ) + fun build(): Scorer = Scorer( + type, + index, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1667,41 +1623,33 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SCORER -> Known.SCORER - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } + fun value(): Value = when (this) { + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1724,18 +1672,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + EXPERIMENT -> Value.EXPERIMENT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + EXPERIMENT -> Known.EXPERIMENT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1743,12 +1688,7 @@ constructor( @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext - private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, - ) { + class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1758,9 +1698,13 @@ constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime() = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -1768,39 +1712,37 @@ constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -1811,8 +1753,7 @@ constructor( private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(runtimeContext: RuntimeContext) = apply { this.runtime = runtimeContext.runtime @@ -1836,44 +1777,39 @@ constructor( this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): RuntimeContext = - RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && this.value == other.value + return other is Runtime && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1900,42 +1836,34 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - NODE -> Value.NODE - PYTHON -> Value.PYTHON - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + NODE -> Value.NODE + PYTHON -> Value.PYTHON + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - NODE -> Known.NODE - PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) - } + fun known(): Known = when (this) { + NODE -> Known.NODE + PYTHON -> Known.PYTHON + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1958,17 +1886,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - BUNDLE -> Value.BUNDLE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + BUNDLE -> Value.BUNDLE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - BUNDLE -> Known.BUNDLE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + BUNDLE -> Known.BUNDLE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1976,12 +1902,12 @@ constructor( @JsonDeserialize(builder = Inline.Builder::class) @NoAutoDetect - class Inline - private constructor( - private val type: JsonField, - private val runtimeContext: JsonField, - private val code: JsonField, - private val additionalProperties: Map, + class Inline private constructor( + private val type: JsonField, + private val runtimeContext: JsonField, + private val code: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1990,18 +1916,21 @@ constructor( fun type(): Type = type.getRequired("type") - fun runtimeContext(): RuntimeContext = - runtimeContext.getRequired("runtime_context") + fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") fun code(): String = code.getRequired("code") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonProperty("runtime_context") @ExcludeMissing fun _runtimeContext() = runtimeContext - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") + @ExcludeMissing + fun _code() = code @JsonAnyGetter @ExcludeMissing @@ -2009,42 +1938,40 @@ constructor( fun validate(): Inline = apply { if (!validated) { - type() - runtimeContext().validate() - code() - validated = true + type() + runtimeContext().validate() + code() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Inline && - this.type == other.type && - this.runtimeContext == other.runtimeContext && - this.code == other.code && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Inline && + this.type == other.type && + this.runtimeContext == other.runtimeContext && + this.code == other.code && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - runtimeContext, - code, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + runtimeContext, + code, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" + override fun toString() = "Inline{type=$type, runtimeContext=$runtimeContext, code=$code, additionalProperties=$additionalProperties}" companion object { @@ -2056,8 +1983,7 @@ constructor( private var type: JsonField = JsonMissing.of() private var runtimeContext: JsonField = JsonMissing.of() private var code: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(inline: Inline) = apply { this.type = inline.type @@ -2070,10 +1996,11 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) + fun runtimeContext(runtimeContext: RuntimeContext) = runtimeContext(JsonField.of(runtimeContext)) @JsonProperty("runtime_context") @ExcludeMissing @@ -2085,40 +2012,35 @@ constructor( @JsonProperty("code") @ExcludeMissing - fun code(code: JsonField) = apply { this.code = code } + fun code(code: JsonField) = apply { + this.code = code + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Inline = - Inline( - type, - runtimeContext, - code, - additionalProperties.toUnmodifiable(), - ) + fun build(): Inline = Inline( + type, + runtimeContext, + code, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = RuntimeContext.Builder::class) @NoAutoDetect - class RuntimeContext - private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, - ) { + class RuntimeContext private constructor(private val runtime: JsonField, private val version: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2128,9 +2050,13 @@ constructor( fun version(): String = version.getRequired("version") - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime + @JsonProperty("runtime") + @ExcludeMissing + fun _runtime() = runtime - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") + @ExcludeMissing + fun _version() = version @JsonAnyGetter @ExcludeMissing @@ -2138,39 +2064,37 @@ constructor( fun validate(): RuntimeContext = apply { if (!validated) { - runtime() - version() - validated = true + runtime() + version() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RuntimeContext && + this.runtime == other.runtime && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + runtime, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -2181,8 +2105,7 @@ constructor( private var runtime: JsonField = JsonMissing.of() private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(runtimeContext: RuntimeContext) = apply { this.runtime = runtimeContext.runtime @@ -2206,44 +2129,39 @@ constructor( this.version = version } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): RuntimeContext = - RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): RuntimeContext = RuntimeContext( + runtime, + version, + additionalProperties.toUnmodifiable(), + ) } - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Runtime @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Runtime && this.value == other.value + return other is Runtime && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2270,42 +2188,34 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - NODE -> Value.NODE - PYTHON -> Value.PYTHON - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + NODE -> Value.NODE + PYTHON -> Value.PYTHON + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - NODE -> Known.NODE - PYTHON -> Known.PYTHON - else -> - throw BraintrustInvalidDataException( - "Unknown Runtime: $value" - ) - } + fun known(): Known = when (this) { + NODE -> Known.NODE + PYTHON -> Known.PYTHON + else -> throw BraintrustInvalidDataException("Unknown Runtime: $value") + } fun asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2328,37 +2238,33 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - INLINE -> Value.INLINE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + INLINE -> Value.INLINE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - INLINE -> Known.INLINE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + INLINE -> Known.INLINE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2381,17 +2287,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CODE -> Value.CODE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + CODE -> Value.CODE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - CODE -> Known.CODE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + CODE -> Known.CODE + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2399,12 +2303,7 @@ constructor( @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect - class Global - private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { + class Global private constructor(private val type: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2414,9 +2313,13 @@ constructor( fun name(): String = name.getRequired("name") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing @@ -2424,39 +2327,37 @@ constructor( fun validate(): Global = apply { if (!validated) { - type() - name() - validated = true + type() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -2479,13 +2380,17 @@ constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2497,33 +2402,29 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Global = - Global( - type, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Global = Global( + type, + name, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2546,17 +2447,15 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2564,10 +2463,7 @@ constructor( @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class NullableVariant - private constructor( - private val additionalProperties: Map, - ) { + class NullableVariant private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2579,26 +2475,26 @@ constructor( fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is NullableVariant && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" @@ -2626,13 +2522,11 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt index 54c6d717..06ab7b1b 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Group.kt @@ -2,38 +2,57 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** * 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 */ @JsonDeserialize(builder = Group.Builder::class) @NoAutoDetect -class Group -private constructor( - private val id: JsonField, - private val orgId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val deletedAt: JsonField, - private val memberUsers: JsonField>, - private val memberGroups: JsonField>, - private val additionalProperties: Map, +class Group private constructor( + private val id: JsonField, + private val orgId: JsonField, + private val userId: JsonField, + private val created: JsonField, + private val name: JsonField, + private val description: JsonField, + private val deletedAt: JsonField, + private val memberUsers: JsonField>, + private val memberGroups: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -71,46 +90,64 @@ 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(): List? = memberGroups.getNullable("member_groups") /** Unique identifier for the group */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** * Unique id for the organization that the group belongs under * * It is forbidden to change the org after creating a group */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId() = orgId /** Identifies the user who created the group */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId /** Date of group creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Textual description of the group */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description() = description /** Date of group deletion, or null if the group is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt() = deletedAt /** Ids of users which belong to this group */ - @JsonProperty("member_users") @ExcludeMissing fun _memberUsers() = memberUsers + @JsonProperty("member_users") + @ExcludeMissing + fun _memberUsers() = memberUsers /** * 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 fun _memberGroups() = memberGroups + @JsonProperty("member_groups") + @ExcludeMissing + fun _memberGroups() = memberGroups @JsonAnyGetter @ExcludeMissing @@ -118,60 +155,58 @@ private constructor( fun validate(): Group = apply { if (!validated) { - id() - orgId() - userId() - created() - name() - description() - deletedAt() - memberUsers() - memberGroups() - validated = true + id() + orgId() + userId() + created() + name() + description() + deletedAt() + memberUsers() + memberGroups() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Group && - this.id == other.id && - this.orgId == other.orgId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.deletedAt == other.deletedAt && - this.memberUsers == other.memberUsers && - this.memberGroups == other.memberGroups && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Group && + this.id == other.id && + this.orgId == other.orgId && + this.userId == other.userId && + this.created == other.created && + this.name == other.name && + this.description == other.description && + this.deletedAt == other.deletedAt && + this.memberUsers == other.memberUsers && + this.memberGroups == other.memberGroups && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - orgId, - userId, - created, - name, - description, - deletedAt, - memberUsers, - memberGroups, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + orgId, + userId, + created, + name, + description, + deletedAt, + memberUsers, + memberGroups, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Group{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberUsers=$memberUsers, memberGroups=$memberGroups, additionalProperties=$additionalProperties}" + override fun toString() = "Group{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberUsers=$memberUsers, memberGroups=$memberGroups, additionalProperties=$additionalProperties}" companion object { @@ -208,7 +243,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the group */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** * Unique id for the organization that the group belongs under @@ -224,7 +263,9 @@ private constructor( */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = apply { + this.orgId = orgId + } /** Identifies the user who created the group */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -232,7 +273,9 @@ private constructor( /** Identifies the user who created the group */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } /** Date of group creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -240,7 +283,9 @@ private constructor( /** Date of group creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** Name of the group */ fun name(name: String) = name(JsonField.of(name)) @@ -248,7 +293,9 @@ private constructor( /** Name of the group */ @JsonProperty("name") @ExcludeMissing - 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.of(description)) @@ -256,7 +303,9 @@ private constructor( /** Textual description of the group */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } /** Date of group deletion, or null if the group is still active */ fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) @@ -264,7 +313,9 @@ private constructor( /** Date of group deletion, or null if the group is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List) = memberUsers(JsonField.of(memberUsers)) @@ -279,16 +330,16 @@ 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(memberGroups: List) = memberGroups(JsonField.of(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 */ @JsonProperty("member_groups") @ExcludeMissing @@ -310,18 +361,17 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Group = - Group( - id, - orgId, - userId, - created, - name, - description, - deletedAt, - memberUsers.map { it.toUnmodifiable() }, - memberGroups.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Group = Group( + id, + orgId, + userId, + created, + name, + description, + deletedAt, + memberUsers.map { it.toUnmodifiable() }, + memberGroups.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt index 2c9c24d1..b85ff8c3 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupCreateParams.kt @@ -2,27 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class GroupCreateParams constructor( + private val name: String, + private val description: String?, + private val memberGroups: List?, + private val memberUsers: List?, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class GroupCreateParams -constructor( - private val name: String, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -36,14 +59,14 @@ constructor( fun orgName(): String? = orgName internal fun getBody(): GroupCreateBody { - return GroupCreateBody( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalBodyProperties, - ) + return GroupCreateBody( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -52,41 +75,46 @@ constructor( @JsonDeserialize(builder = GroupCreateBody.Builder::class) @NoAutoDetect - class GroupCreateBody - internal constructor( - private val name: String?, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, - private val additionalProperties: Map, + class GroupCreateBody internal constructor( + private val name: String?, + private val description: String?, + private val memberGroups: List?, + private val memberUsers: List?, + private val orgName: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the group */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Textual description of the group */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = 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") fun memberGroups(): List? = memberGroups + @JsonProperty("member_groups") + fun memberGroups(): List? = memberGroups /** Ids of users which belong to this group */ - @JsonProperty("member_users") fun memberUsers(): List? = memberUsers + @JsonProperty("member_users") + fun memberUsers(): List? = 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") fun orgName(): String? = orgName + @JsonProperty("org_name") + fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -95,36 +123,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupCreateBody && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GroupCreateBody && + this.name == other.name && + this.description == other.description && + this.memberGroups == other.memberGroups && + this.memberUsers == other.memberUsers && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "GroupCreateBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { @@ -150,17 +176,22 @@ constructor( } /** Name of the group */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Textual description of the group */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = 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 */ @JsonProperty("member_groups") fun memberGroups(memberGroups: List) = apply { @@ -169,15 +200,19 @@ constructor( /** Ids of users which belong to this group */ @JsonProperty("member_users") - fun memberUsers(memberUsers: List) = apply { this.memberUsers = memberUsers } + fun memberUsers(memberUsers: List) = apply { + this.memberUsers = 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") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -193,15 +228,16 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupCreateBody = - GroupCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - description, - memberGroups?.toUnmodifiable(), - memberUsers?.toUnmodifiable(), - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): GroupCreateBody = GroupCreateBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + description, + memberGroups?.toUnmodifiable(), + memberUsers?.toUnmodifiable(), + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -212,36 +248,35 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupCreateParams && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is GroupCreateParams && + this.name == other.name && + this.description == other.description && + this.memberGroups == other.memberGroups && + this.memberUsers == other.memberUsers && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "GroupCreateParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "GroupCreateParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -274,16 +309,20 @@ constructor( } /** Name of the group */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Textual description of the group */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = 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) = apply { this.memberGroups.clear() @@ -293,10 +332,12 @@ 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 addMemberGroup(memberGroup: String) = apply { this.memberGroups.add(memberGroup) } + fun addMemberGroup(memberGroup: String) = apply { + this.memberGroups.add(memberGroup) + } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List) = apply { @@ -305,14 +346,18 @@ constructor( } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { this.memberUsers.add(memberUser) } + fun addMemberUser(memberUser: String) = apply { + this.memberUsers.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) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -352,7 +397,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -363,21 +410,21 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): GroupCreateParams = - GroupCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - description, - if (memberGroups.size == 0) null else memberGroups.toUnmodifiable(), - if (memberUsers.size == 0) null else memberUsers.toUnmodifiable(), - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): GroupCreateParams = GroupCreateParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + description, + if(memberGroups.size == 0) null else memberGroups.toUnmodifiable(), + if(memberUsers.size == 0) null else memberUsers.toUnmodifiable(), + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt index dcb3e53d..904b3767 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class GroupDeleteParams -constructor( - private val groupId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class GroupDeleteParams constructor( + private val groupId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun groupId(): String = groupId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupDeleteParams && - this.groupId == other.groupId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is GroupDeleteParams && + this.groupId == other.groupId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - groupId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + groupId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "GroupDeleteParams{groupId=$groupId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "GroupDeleteParams{groupId=$groupId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** Group id */ - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String) = apply { + this.groupId = groupId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): GroupDeleteParams = - GroupDeleteParams( - checkNotNull(groupId) { "`groupId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): GroupDeleteParams = GroupDeleteParams( + checkNotNull(groupId) { + "`groupId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt index 7590fe5a..e15a08c6 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPage.kt @@ -2,97 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Group import com.braintrustdata.api.services.blocking.GroupService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class GroupListPage -private constructor( - private val groupService: GroupService, - private val params: GroupListParams, - private val response: Response, -) { +class GroupListPage private constructor(private val groupService: GroupService, private val params: GroupListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupListPage && - this.groupService == other.groupService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is GroupListPage && + this.groupService == other.groupService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - groupService, - params, - response, - ) + return Objects.hash( + groupService, + params, + response, + ) } - override fun toString() = - "GroupListPage{groupService=$groupService, params=$params, response=$response}" + override fun toString() = "GroupListPage{groupService=$groupService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): GroupListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - GroupListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - GroupListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + GroupListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + GroupListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): GroupListPage? { - return getNextPageParams()?.let { groupService.list(it) } + return getNextPageParams()?.let { + groupService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(groupService: GroupService, params: GroupListParams, response: Response) = - GroupListPage( - groupService, - params, - response, - ) + fun of(groupService: GroupService, params: GroupListParams, response: Response) = GroupListPage( + groupService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -100,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "GroupListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "GroupListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -153,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: GroupListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: GroupListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt index c2e51a2e..9df06760 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListPageAsync.kt @@ -2,99 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.GroupServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Group +import com.braintrustdata.api.services.async.GroupServiceAsync -class GroupListPageAsync -private constructor( - private val groupService: GroupServiceAsync, - private val params: GroupListParams, - private val response: Response, -) { +class GroupListPageAsync private constructor(private val groupService: GroupServiceAsync, private val params: GroupListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupListPageAsync && - this.groupService == other.groupService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is GroupListPageAsync && + this.groupService == other.groupService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - groupService, - params, - response, - ) + return Objects.hash( + groupService, + params, + response, + ) } - override fun toString() = - "GroupListPageAsync{groupService=$groupService, params=$params, response=$response}" + override fun toString() = "GroupListPageAsync{groupService=$groupService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): GroupListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - GroupListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - GroupListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + GroupListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + GroupListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): GroupListPageAsync? { - return getNextPageParams()?.let { groupService.list(it) } + return getNextPageParams()?.let { + groupService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(groupService: GroupServiceAsync, params: GroupListParams, response: Response) = - GroupListPageAsync( - groupService, - params, - response, - ) + fun of(groupService: GroupServiceAsync, params: GroupListParams, response: Response) = GroupListPageAsync( + groupService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -102,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "GroupListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "GroupListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -155,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: GroupListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: GroupListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt index fd5d6cb3..14452dec 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupListParams.kt @@ -2,33 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class GroupListParams constructor( + private val endingBefore: String?, + private val groupName: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class GroupListParams -constructor( - private val endingBefore: String?, - private val groupName: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun endingBefore(): String? = endingBefore @@ -44,15 +61,27 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.groupName?.let { params.put("group_name", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.groupName?.let { + params.put("group_name", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -62,36 +91,35 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupListParams && - this.endingBefore == other.endingBefore && - this.groupName == other.groupName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is GroupListParams && + this.endingBefore == other.endingBefore && + this.groupName == other.groupName && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - groupName, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + endingBefore, + groupName, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "GroupListParams{endingBefore=$endingBefore, groupName=$groupName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -126,47 +154,63 @@ 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 + } /** Name of the group to search for */ - fun groupName(groupName: String) = apply { this.groupName = groupName } + fun groupName(groupName: String) = apply { + this.groupName = 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(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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -206,82 +250,77 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): GroupListParams = - GroupListParams( - endingBefore, - groupName, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): GroupListParams = GroupListParams( + endingBefore, + groupName, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -298,38 +337,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt index 36d0db55..d7f1c9a3 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupReplaceParams.kt @@ -2,27 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class GroupReplaceParams constructor( + private val name: String, + private val description: String?, + private val memberGroups: List?, + private val memberUsers: List?, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class GroupReplaceParams -constructor( - private val name: String, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -36,14 +59,14 @@ constructor( fun orgName(): String? = orgName internal fun getBody(): GroupReplaceBody { - return GroupReplaceBody( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalBodyProperties, - ) + return GroupReplaceBody( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -52,41 +75,46 @@ constructor( @JsonDeserialize(builder = GroupReplaceBody.Builder::class) @NoAutoDetect - class GroupReplaceBody - internal constructor( - private val name: String?, - private val description: String?, - private val memberGroups: List?, - private val memberUsers: List?, - private val orgName: String?, - private val additionalProperties: Map, + class GroupReplaceBody internal constructor( + private val name: String?, + private val description: String?, + private val memberGroups: List?, + private val memberUsers: List?, + private val orgName: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the group */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Textual description of the group */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = 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") fun memberGroups(): List? = memberGroups + @JsonProperty("member_groups") + fun memberGroups(): List? = memberGroups /** Ids of users which belong to this group */ - @JsonProperty("member_users") fun memberUsers(): List? = memberUsers + @JsonProperty("member_users") + fun memberUsers(): List? = 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") fun orgName(): String? = orgName + @JsonProperty("org_name") + fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -95,36 +123,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupReplaceBody && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GroupReplaceBody && + this.name == other.name && + this.description == other.description && + this.memberGroups == other.memberGroups && + this.memberUsers == other.memberUsers && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "GroupReplaceBody{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { @@ -150,17 +176,22 @@ constructor( } /** Name of the group */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Textual description of the group */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = 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 */ @JsonProperty("member_groups") fun memberGroups(memberGroups: List) = apply { @@ -169,15 +200,19 @@ constructor( /** Ids of users which belong to this group */ @JsonProperty("member_users") - fun memberUsers(memberUsers: List) = apply { this.memberUsers = memberUsers } + fun memberUsers(memberUsers: List) = apply { + this.memberUsers = 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") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -193,15 +228,16 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupReplaceBody = - GroupReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - description, - memberGroups?.toUnmodifiable(), - memberUsers?.toUnmodifiable(), - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): GroupReplaceBody = GroupReplaceBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + description, + memberGroups?.toUnmodifiable(), + memberUsers?.toUnmodifiable(), + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -212,36 +248,35 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupReplaceParams && - this.name == other.name && - this.description == other.description && - this.memberGroups == other.memberGroups && - this.memberUsers == other.memberUsers && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is GroupReplaceParams && + this.name == other.name && + this.description == other.description && + this.memberGroups == other.memberGroups && + this.memberUsers == other.memberUsers && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberGroups, - memberUsers, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + description, + memberGroups, + memberUsers, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "GroupReplaceParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "GroupReplaceParams{name=$name, description=$description, memberGroups=$memberGroups, memberUsers=$memberUsers, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -274,16 +309,20 @@ constructor( } /** Name of the group */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Textual description of the group */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = 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) = apply { this.memberGroups.clear() @@ -293,10 +332,12 @@ 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 addMemberGroup(memberGroup: String) = apply { this.memberGroups.add(memberGroup) } + fun addMemberGroup(memberGroup: String) = apply { + this.memberGroups.add(memberGroup) + } /** Ids of users which belong to this group */ fun memberUsers(memberUsers: List) = apply { @@ -305,14 +346,18 @@ constructor( } /** Ids of users which belong to this group */ - fun addMemberUser(memberUser: String) = apply { this.memberUsers.add(memberUser) } + fun addMemberUser(memberUser: String) = apply { + this.memberUsers.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) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -352,7 +397,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -363,21 +410,21 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): GroupReplaceParams = - GroupReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - description, - if (memberGroups.size == 0) null else memberGroups.toUnmodifiable(), - if (memberUsers.size == 0) null else memberUsers.toUnmodifiable(), - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): GroupReplaceParams = GroupReplaceParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + description, + if(memberGroups.size == 0) null else memberGroups.toUnmodifiable(), + if(memberUsers.size == 0) null else memberUsers.toUnmodifiable(), + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt index fd99d2c5..0864fbab 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class GroupRetrieveParams -constructor( - private val groupId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class GroupRetrieveParams constructor(private val groupId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun groupId(): String = groupId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupRetrieveParams && - this.groupId == other.groupId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is GroupRetrieveParams && + this.groupId == other.groupId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - groupId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + groupId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "GroupRetrieveParams{groupId=$groupId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "GroupRetrieveParams{groupId=$groupId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** Group id */ - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String) = apply { + this.groupId = groupId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): GroupRetrieveParams = - GroupRetrieveParams( - checkNotNull(groupId) { "`groupId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): GroupRetrieveParams = GroupRetrieveParams( + checkNotNull(groupId) { + "`groupId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt index 17a819ea..589472de 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/GroupUpdateParams.kt @@ -2,29 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class GroupUpdateParams constructor( + private val groupId: String, + private val addMemberGroups: List?, + private val addMemberUsers: List?, + private val description: String?, + private val name: String?, + private val removeMemberGroups: List?, + private val removeMemberUsers: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class GroupUpdateParams -constructor( - private val groupId: String, - private val addMemberGroups: List?, - private val addMemberUsers: List?, - private val description: String?, - private val name: String?, - private val removeMemberGroups: List?, - private val removeMemberUsers: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun groupId(): String = groupId @@ -42,15 +65,15 @@ constructor( fun removeMemberUsers(): List? = removeMemberUsers internal fun getBody(): GroupUpdateBody { - return GroupUpdateBody( - addMemberGroups, - addMemberUsers, - description, - name, - removeMemberGroups, - removeMemberUsers, - additionalBodyProperties, - ) + return GroupUpdateBody( + addMemberGroups, + addMemberUsers, + description, + name, + removeMemberGroups, + removeMemberUsers, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -58,38 +81,42 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> groupId - else -> "" - } + return when (index) { + 0 -> groupId + else -> "" + } } @JsonDeserialize(builder = GroupUpdateBody.Builder::class) @NoAutoDetect - class GroupUpdateBody - internal constructor( - private val addMemberGroups: List?, - private val addMemberUsers: List?, - private val description: String?, - private val name: String?, - private val removeMemberGroups: List?, - private val removeMemberUsers: List?, - private val additionalProperties: Map, + class GroupUpdateBody internal constructor( + private val addMemberGroups: List?, + private val addMemberUsers: List?, + private val description: String?, + private val name: String?, + private val removeMemberGroups: List?, + private val removeMemberUsers: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** A list of group IDs to add to the group's inheriting-from set */ - @JsonProperty("add_member_groups") fun addMemberGroups(): List? = addMemberGroups + @JsonProperty("add_member_groups") + fun addMemberGroups(): List? = addMemberGroups /** A list of user IDs to add to the group */ - @JsonProperty("add_member_users") fun addMemberUsers(): List? = addMemberUsers + @JsonProperty("add_member_users") + fun addMemberUsers(): List? = addMemberUsers /** Textual description of the group */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description /** Name of the group */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** A list of group IDs to remove from the group's inheriting-from set */ @JsonProperty("remove_member_groups") @@ -106,38 +133,36 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupUpdateBody && - this.addMemberGroups == other.addMemberGroups && - this.addMemberUsers == other.addMemberUsers && - this.description == other.description && - this.name == other.name && - this.removeMemberGroups == other.removeMemberGroups && - this.removeMemberUsers == other.removeMemberUsers && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GroupUpdateBody && + this.addMemberGroups == other.addMemberGroups && + this.addMemberUsers == other.addMemberUsers && + this.description == other.description && + this.name == other.name && + this.removeMemberGroups == other.removeMemberGroups && + this.removeMemberUsers == other.removeMemberUsers && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - addMemberGroups, - addMemberUsers, - description, - name, - removeMemberGroups, - removeMemberUsers, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + addMemberGroups, + addMemberUsers, + description, + name, + removeMemberGroups, + removeMemberUsers, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" + override fun toString() = "GroupUpdateBody{addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalProperties=$additionalProperties}" companion object { @@ -178,10 +203,15 @@ constructor( /** Textual description of the group */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Name of the group */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** A list of group IDs to remove from the group's inheriting-from set */ @JsonProperty("remove_member_groups") @@ -209,16 +239,15 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): GroupUpdateBody = - GroupUpdateBody( - addMemberGroups?.toUnmodifiable(), - addMemberUsers?.toUnmodifiable(), - description, - name, - removeMemberGroups?.toUnmodifiable(), - removeMemberUsers?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): GroupUpdateBody = GroupUpdateBody( + addMemberGroups?.toUnmodifiable(), + addMemberUsers?.toUnmodifiable(), + description, + name, + removeMemberGroups?.toUnmodifiable(), + removeMemberUsers?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -229,40 +258,39 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GroupUpdateParams && - this.groupId == other.groupId && - this.addMemberGroups == other.addMemberGroups && - this.addMemberUsers == other.addMemberUsers && - this.description == other.description && - this.name == other.name && - this.removeMemberGroups == other.removeMemberGroups && - this.removeMemberUsers == other.removeMemberUsers && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is GroupUpdateParams && + this.groupId == other.groupId && + this.addMemberGroups == other.addMemberGroups && + this.addMemberUsers == other.addMemberUsers && + this.description == other.description && + this.name == other.name && + this.removeMemberGroups == other.removeMemberGroups && + this.removeMemberUsers == other.removeMemberUsers && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - groupId, - addMemberGroups, - addMemberUsers, - description, - name, - removeMemberGroups, - removeMemberUsers, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + groupId, + addMemberGroups, + addMemberUsers, + description, + name, + removeMemberGroups, + removeMemberUsers, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "GroupUpdateParams{groupId=$groupId, addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "GroupUpdateParams{groupId=$groupId, addMemberGroups=$addMemberGroups, addMemberUsers=$addMemberUsers, description=$description, name=$name, removeMemberGroups=$removeMemberGroups, removeMemberUsers=$removeMemberUsers, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -299,7 +327,9 @@ constructor( } /** 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 { @@ -324,10 +354,14 @@ constructor( } /** Textual description of the group */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Name of the group */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** A list of group IDs to remove from the group's inheriting-from set */ fun removeMemberGroups(removeMemberGroups: List) = apply { @@ -389,7 +423,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -400,23 +436,23 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): GroupUpdateParams = - GroupUpdateParams( - checkNotNull(groupId) { "`groupId` is required but was not set" }, - if (addMemberGroups.size == 0) null else addMemberGroups.toUnmodifiable(), - if (addMemberUsers.size == 0) null else addMemberUsers.toUnmodifiable(), - description, - name, - if (removeMemberGroups.size == 0) null else removeMemberGroups.toUnmodifiable(), - if (removeMemberUsers.size == 0) null else removeMemberUsers.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): GroupUpdateParams = GroupUpdateParams( + checkNotNull(groupId) { + "`groupId` is required but was not set" + }, + if(addMemberGroups.size == 0) null else addMemberGroups.toUnmodifiable(), + if(addMemberUsers.size == 0) null else addMemberUsers.toUnmodifiable(), + description, + name, + if(removeMemberGroups.size == 0) null else removeMemberGroups.toUnmodifiable(), + if(removeMemberUsers.size == 0) null else removeMemberUsers.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Ids.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Ids.kt deleted file mode 100755 index a1f97033..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Ids.kt +++ /dev/null @@ -1,126 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(using = Ids.Deserializer::class) -@JsonSerialize(using = Ids.Serializer::class) -class Ids -private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun string(): String? = string - - fun strings(): List? = strings - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Ids = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Ids && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } - } - - companion object { - - fun ofString(string: String) = Ids(string = string) - - fun ofStrings(strings: List) = Ids(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") - } - } - - class Deserializer : BaseDeserializer(Ids::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) - } - } - - class Serializer : BaseSerializer(Ids::class) { - - override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt deleted file mode 100755 index 24e2748d..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEvent.kt +++ /dev/null @@ -1,146 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(using = InsertDatasetEvent.Deserializer::class) -@JsonSerialize(using = InsertDatasetEvent.Serializer::class) -class InsertDatasetEvent -private constructor( - private val insertDatasetEventReplace: InsertDatasetEventReplace? = null, - private val insertDatasetEventMerge: InsertDatasetEventMerge? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun insertDatasetEventReplace(): InsertDatasetEventReplace? = insertDatasetEventReplace - - fun insertDatasetEventMerge(): InsertDatasetEventMerge? = insertDatasetEventMerge - - fun isInsertDatasetEventReplace(): Boolean = insertDatasetEventReplace != null - - fun isInsertDatasetEventMerge(): Boolean = insertDatasetEventMerge != null - - fun asInsertDatasetEventReplace(): InsertDatasetEventReplace = - insertDatasetEventReplace.getOrThrow("insertDatasetEventReplace") - - fun asInsertDatasetEventMerge(): InsertDatasetEventMerge = - insertDatasetEventMerge.getOrThrow("insertDatasetEventMerge") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - insertDatasetEventReplace != null -> - visitor.visitInsertDatasetEventReplace(insertDatasetEventReplace) - insertDatasetEventMerge != null -> - visitor.visitInsertDatasetEventMerge(insertDatasetEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): InsertDatasetEvent = apply { - if (!validated) { - if (insertDatasetEventReplace == null && insertDatasetEventMerge == null) { - throw BraintrustInvalidDataException("Unknown InsertDatasetEvent: $_json") - } - insertDatasetEventReplace?.validate() - insertDatasetEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertDatasetEvent && - this.insertDatasetEventReplace == other.insertDatasetEventReplace && - this.insertDatasetEventMerge == other.insertDatasetEventMerge - } - - override fun hashCode(): Int { - return Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) - } - - override fun toString(): String { - return when { - insertDatasetEventReplace != null -> - "InsertDatasetEvent{insertDatasetEventReplace=$insertDatasetEventReplace}" - insertDatasetEventMerge != null -> - "InsertDatasetEvent{insertDatasetEventMerge=$insertDatasetEventMerge}" - _json != null -> "InsertDatasetEvent{_unknown=$_json}" - else -> throw IllegalStateException("Invalid InsertDatasetEvent") - } - } - - companion object { - - fun ofInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace) = - InsertDatasetEvent(insertDatasetEventReplace = insertDatasetEventReplace) - - fun ofInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge) = - InsertDatasetEvent(insertDatasetEventMerge = insertDatasetEventMerge) - } - - interface Visitor { - - fun visitInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace): T - - fun visitInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown InsertDatasetEvent: $json") - } - } - - class Deserializer : BaseDeserializer(InsertDatasetEvent::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): InsertDatasetEvent { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return InsertDatasetEvent(insertDatasetEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return InsertDatasetEvent(insertDatasetEventMerge = it, _json = json) - } - - return InsertDatasetEvent(_json = json) - } - } - - class Serializer : BaseSerializer(InsertDatasetEvent::class) { - - override fun serialize( - value: InsertDatasetEvent, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertDatasetEventReplace != null -> - generator.writeObject(value.insertDatasetEventReplace) - value.insertDatasetEventMerge != null -> - generator.writeObject(value.insertDatasetEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid InsertDatasetEvent") - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt index 4990ff65..c3b442d3 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventMerge.kt @@ -2,54 +2,75 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = InsertDatasetEventMerge.Builder::class) @NoAutoDetect -class InsertDatasetEventMerge -private constructor( - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val additionalProperties: Map, +class InsertDatasetEventMerge private constructor( + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _mergePaths: JsonField>>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - /** 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(): JsonValue = input /** - * 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) */ fun expected(): JsonValue = expected /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else 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.getNullable("metadata") @@ -57,8 +78,8 @@ private constructor( fun tags(): List? = 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 */ fun id(): String? = id.getNullable("id") @@ -66,102 +87,131 @@ private constructor( fun created(): OffsetDateTime? = created.getNullable("created") /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ fun _objectDelete(): Boolean? = _objectDelete.getNullable("_object_delete") /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * 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(): List>? = _mergePaths.getNullable("_merge_paths") - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable + * The argument that uniquely define an input case (an arbitrary, JSON serializable * object) */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("input") + @ExcludeMissing + fun _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 + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected + + /** + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") + @ExcludeMissing + fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge() = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + @JsonProperty("_merge_paths") + @ExcludeMissing + fun __mergePaths() = _mergePaths @JsonAnyGetter @ExcludeMissing @@ -169,60 +219,58 @@ private constructor( fun validate(): InsertDatasetEventMerge = apply { if (!validated) { - input() - expected() - metadata()?.validate() - tags() - id() - created() - _objectDelete() - _isMerge() - _mergePaths() - validated = true + input() + expected() + metadata()?.validate() + tags() + id() + created() + _objectDelete() + _isMerge() + _mergePaths() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertDatasetEventMerge && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertDatasetEventMerge && + this.input == other.input && + this.expected == other.expected && + this.metadata == other.metadata && + this.tags == other.tags && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._mergePaths == other._mergePaths && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - expected, - metadata, - tags, - id, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + input, + expected, + metadata, + tags, + id, + created, + _objectDelete, + _isMerge, + _mergePaths, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "InsertDatasetEventMerge{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + override fun toString() = "InsertDatasetEventMerge{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" companion object { @@ -256,11 +304,14 @@ private constructor( } /** - * 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) */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { + this.input = input + } /** * The output of your application, including post-processing (an arbitrary, JSON @@ -268,27 +319,31 @@ private constructor( */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -296,19 +351,25 @@ private constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * 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 */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -316,17 +377,19 @@ private constructor( /** The timestamp the dataset event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * 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 @@ -335,64 +398,70 @@ private constructor( } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = apply { + this._isMerge = _isMerge + } /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * 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 @@ -414,34 +483,30 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): InsertDatasetEventMerge = - InsertDatasetEventMerge( - input, - expected, - metadata, - tags.map { it.toUnmodifiable() }, - id, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertDatasetEventMerge = InsertDatasetEventMerge( + input, + expected, + metadata, + tags.map { it.toUnmodifiable() }, + id, + created, + _objectDelete, + _isMerge, + _mergePaths.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else 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 */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -453,25 +518,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt index 6e21cffe..ccf3ac5e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplace.kt @@ -2,54 +2,75 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = InsertDatasetEventReplace.Builder::class) @NoAutoDetect -class InsertDatasetEventReplace -private constructor( - private val input: JsonValue, - private val expected: JsonValue, - private val metadata: JsonField, - private val tags: JsonField>, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, +class InsertDatasetEventReplace private constructor( + private val input: JsonValue, + private val expected: JsonValue, + private val metadata: JsonField, + private val tags: JsonField>, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _parentId: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - /** 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(): JsonValue = input /** - * 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) */ fun expected(): JsonValue = expected /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else 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.getNullable("metadata") @@ -57,8 +78,8 @@ private constructor( fun tags(): List? = 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 */ fun id(): String? = id.getNullable("id") @@ -66,100 +87,129 @@ private constructor( fun created(): OffsetDateTime? = created.getNullable("created") /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ fun _objectDelete(): Boolean? = _objectDelete.getNullable("_object_delete") /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Boolean? = _isMerge.getNullable("_is_merge") /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ fun _parentId(): String? = _parentId.getNullable("_parent_id") - /** The argument that uniquely define an input case (an arbitrary, JSON serializable object) */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - /** - * The output of your application, including post-processing (an arbitrary, JSON serializable + * The argument that uniquely define an input case (an arbitrary, JSON serializable * object) */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("input") + @ExcludeMissing + fun _input() = input + + /** + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object) + */ + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate - * one for you + * A unique identifier for the dataset event. If you don't provide one, BrainTrust + * will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** The timestamp the dataset event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not show up - * in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") + @ExcludeMissing + fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge() = _isMerge /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + @JsonProperty("_parent_id") + @ExcludeMissing + fun __parentId() = _parentId @JsonAnyGetter @ExcludeMissing @@ -167,60 +217,58 @@ private constructor( fun validate(): InsertDatasetEventReplace = apply { if (!validated) { - input() - expected() - metadata()?.validate() - tags() - id() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true + input() + expected() + metadata()?.validate() + tags() + id() + created() + _objectDelete() + _isMerge() + _parentId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertDatasetEventReplace && - this.input == other.input && - this.expected == other.expected && - this.metadata == other.metadata && - this.tags == other.tags && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertDatasetEventReplace && + this.input == other.input && + this.expected == other.expected && + this.metadata == other.metadata && + this.tags == other.tags && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._parentId == other._parentId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - expected, - metadata, - tags, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + input, + expected, + metadata, + tags, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "InsertDatasetEventReplace{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" + override fun toString() = "InsertDatasetEventReplace{input=$input, expected=$expected, metadata=$metadata, tags=$tags, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" companion object { @@ -254,11 +302,14 @@ private constructor( } /** - * 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) */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { + this.input = input + } /** * The output of your application, including post-processing (an arbitrary, JSON @@ -266,27 +317,31 @@ private constructor( */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -294,19 +349,25 @@ private constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** - * A unique identifier for the dataset event. If you don't provide one, BrainTrust will - * generate one for you + * 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 */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** The timestamp the dataset event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -314,17 +375,19 @@ private constructor( /** The timestamp the dataset event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events + * will not show up in subsequent fetches for this dataset */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) /** - * Pass `_object_delete=true` to mark the dataset event deleted. Deleted events will not - * show up in subsequent fetches for this dataset + * 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 @@ -333,66 +396,74 @@ private constructor( } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = apply { + this._isMerge = _isMerge + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ @JsonProperty("_parent_id") @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun _parentId(_parentId: JsonField) = apply { + this._parentId = _parentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -408,34 +479,30 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): InsertDatasetEventReplace = - InsertDatasetEventReplace( - input, - expected, - metadata, - tags.map { it.toUnmodifiable() }, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertDatasetEventReplace = InsertDatasetEventReplace( + input, + expected, + metadata, + tags.map { it.toUnmodifiable() }, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties.toUnmodifiable(), + ) } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else 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 */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -447,25 +514,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequest.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequest.kt deleted file mode 100755 index a7e60df7..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequest.kt +++ /dev/null @@ -1,252 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(builder = InsertDatasetEventRequest.Builder::class) -@NoAutoDetect -class InsertDatasetEventRequest -private constructor( - private val events: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of dataset events to insert */ - fun events(): List = events.getRequired("events") - - /** A list of dataset events to insert */ - @JsonProperty("events") @ExcludeMissing fun _events() = events - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertDatasetEventRequest = apply { - if (!validated) { - events() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertDatasetEventRequest && - this.events == other.events && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode - } - - override fun toString() = - "InsertDatasetEventRequest{events=$events, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var events: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(insertDatasetEventRequest: InsertDatasetEventRequest) = apply { - this.events = insertDatasetEventRequest.events - additionalProperties(insertDatasetEventRequest.additionalProperties) - } - - /** A list of dataset events to insert */ - fun events(events: List) = events(JsonField.of(events)) - - /** A list of dataset events to insert */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InsertDatasetEventRequest = - InsertDatasetEventRequest( - events.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } - - @JsonDeserialize(using = Event.Deserializer::class) - @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertDatasetEventReplace: InsertDatasetEventReplace? = null, - private val insertDatasetEventMerge: InsertDatasetEventMerge? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun insertDatasetEventReplace(): InsertDatasetEventReplace? = insertDatasetEventReplace - - fun insertDatasetEventMerge(): InsertDatasetEventMerge? = insertDatasetEventMerge - - fun isInsertDatasetEventReplace(): Boolean = insertDatasetEventReplace != null - - fun isInsertDatasetEventMerge(): Boolean = insertDatasetEventMerge != null - - fun asInsertDatasetEventReplace(): InsertDatasetEventReplace = - insertDatasetEventReplace.getOrThrow("insertDatasetEventReplace") - - fun asInsertDatasetEventMerge(): InsertDatasetEventMerge = - insertDatasetEventMerge.getOrThrow("insertDatasetEventMerge") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - insertDatasetEventReplace != null -> - visitor.visitInsertDatasetEventReplace(insertDatasetEventReplace) - insertDatasetEventMerge != null -> - visitor.visitInsertDatasetEventMerge(insertDatasetEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): Event = apply { - if (!validated) { - if (insertDatasetEventReplace == null && insertDatasetEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertDatasetEventReplace?.validate() - insertDatasetEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.insertDatasetEventReplace == other.insertDatasetEventReplace && - this.insertDatasetEventMerge == other.insertDatasetEventMerge - } - - override fun hashCode(): Int { - return Objects.hash(insertDatasetEventReplace, insertDatasetEventMerge) - } - - override fun toString(): String { - return when { - insertDatasetEventReplace != null -> - "Event{insertDatasetEventReplace=$insertDatasetEventReplace}" - insertDatasetEventMerge != null -> - "Event{insertDatasetEventMerge=$insertDatasetEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } - } - - companion object { - - fun ofInsertDatasetEventReplace(insertDatasetEventReplace: InsertDatasetEventReplace) = - Event(insertDatasetEventReplace = insertDatasetEventReplace) - - fun ofInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge) = - Event(insertDatasetEventMerge = insertDatasetEventMerge) - } - - interface Visitor { - - fun visitInsertDatasetEventReplace( - insertDatasetEventReplace: InsertDatasetEventReplace - ): T - - fun visitInsertDatasetEventMerge(insertDatasetEventMerge: InsertDatasetEventMerge): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") - } - } - - class Deserializer : BaseDeserializer(Event::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertDatasetEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertDatasetEventMerge = it, _json = json) - } - - return Event(_json = json) - } - } - - class Serializer : BaseSerializer(Event::class) { - - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertDatasetEventReplace != null -> - generator.writeObject(value.insertDatasetEventReplace) - value.insertDatasetEventMerge != null -> - generator.writeObject(value.insertDatasetEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt index 62ed4675..97ad3cb5 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertEventsResponse.kt @@ -2,39 +2,58 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = InsertEventsResponse.Builder::class) @NoAutoDetect -class InsertEventsResponse -private constructor( - private val rowIds: JsonField>, - private val additionalProperties: Map, -) { +class InsertEventsResponse private constructor(private val rowIds: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false private var hashCode: Int = 0 /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input + * 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() = rowIds + @JsonProperty("row_ids") + @ExcludeMissing + fun _rowIds() = rowIds @JsonAnyGetter @ExcludeMissing @@ -42,32 +61,31 @@ private constructor( fun validate(): InsertEventsResponse = apply { if (!validated) { - rowIds() - validated = true + rowIds() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is InsertEventsResponse && - this.rowIds == other.rowIds && - this.additionalProperties == other.additionalProperties + return other is InsertEventsResponse && + this.rowIds == other.rowIds && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(rowIds, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(rowIds, additionalProperties) + } + return hashCode } - override fun toString() = - "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" + override fun toString() = "InsertEventsResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" companion object { @@ -85,18 +103,20 @@ private constructor( } /** - * 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 */ @JsonProperty("row_ids") @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } + fun rowIds(rowIds: JsonField>) = apply { + this.rowIds = rowIds + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -112,10 +132,6 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): InsertEventsResponse = - InsertEventsResponse( - rowIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) + fun build(): InsertEventsResponse = InsertEventsResponse(rowIds.map { it.toUnmodifiable() }, additionalProperties.toUnmodifiable()) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt deleted file mode 100755 index ad6d6742..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEvent.kt +++ /dev/null @@ -1,151 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(using = InsertExperimentEvent.Deserializer::class) -@JsonSerialize(using = InsertExperimentEvent.Serializer::class) -class InsertExperimentEvent -private constructor( - private val insertExperimentEventReplace: InsertExperimentEventReplace? = null, - private val insertExperimentEventMerge: InsertExperimentEventMerge? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun insertExperimentEventReplace(): InsertExperimentEventReplace? = insertExperimentEventReplace - - fun insertExperimentEventMerge(): InsertExperimentEventMerge? = insertExperimentEventMerge - - fun isInsertExperimentEventReplace(): Boolean = insertExperimentEventReplace != null - - fun isInsertExperimentEventMerge(): Boolean = insertExperimentEventMerge != null - - fun asInsertExperimentEventReplace(): InsertExperimentEventReplace = - insertExperimentEventReplace.getOrThrow("insertExperimentEventReplace") - - fun asInsertExperimentEventMerge(): InsertExperimentEventMerge = - insertExperimentEventMerge.getOrThrow("insertExperimentEventMerge") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - insertExperimentEventReplace != null -> - visitor.visitInsertExperimentEventReplace(insertExperimentEventReplace) - insertExperimentEventMerge != null -> - visitor.visitInsertExperimentEventMerge(insertExperimentEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): InsertExperimentEvent = apply { - if (!validated) { - if (insertExperimentEventReplace == null && insertExperimentEventMerge == null) { - throw BraintrustInvalidDataException("Unknown InsertExperimentEvent: $_json") - } - insertExperimentEventReplace?.validate() - insertExperimentEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertExperimentEvent && - this.insertExperimentEventReplace == other.insertExperimentEventReplace && - this.insertExperimentEventMerge == other.insertExperimentEventMerge - } - - override fun hashCode(): Int { - return Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) - } - - override fun toString(): String { - return when { - insertExperimentEventReplace != null -> - "InsertExperimentEvent{insertExperimentEventReplace=$insertExperimentEventReplace}" - insertExperimentEventMerge != null -> - "InsertExperimentEvent{insertExperimentEventMerge=$insertExperimentEventMerge}" - _json != null -> "InsertExperimentEvent{_unknown=$_json}" - else -> throw IllegalStateException("Invalid InsertExperimentEvent") - } - } - - companion object { - - fun ofInsertExperimentEventReplace( - insertExperimentEventReplace: InsertExperimentEventReplace - ) = InsertExperimentEvent(insertExperimentEventReplace = insertExperimentEventReplace) - - fun ofInsertExperimentEventMerge(insertExperimentEventMerge: InsertExperimentEventMerge) = - InsertExperimentEvent(insertExperimentEventMerge = insertExperimentEventMerge) - } - - interface Visitor { - - fun visitInsertExperimentEventReplace( - insertExperimentEventReplace: InsertExperimentEventReplace - ): T - - fun visitInsertExperimentEventMerge( - insertExperimentEventMerge: InsertExperimentEventMerge - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown InsertExperimentEvent: $json") - } - } - - class Deserializer : BaseDeserializer(InsertExperimentEvent::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): InsertExperimentEvent { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return InsertExperimentEvent(insertExperimentEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return InsertExperimentEvent(insertExperimentEventMerge = it, _json = json) - } - - return InsertExperimentEvent(_json = json) - } - } - - class Serializer : BaseSerializer(InsertExperimentEvent::class) { - - override fun serialize( - value: InsertExperimentEvent, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertExperimentEventReplace != null -> - generator.writeObject(value.insertExperimentEventReplace) - value.insertExperimentEventMerge != null -> - generator.writeObject(value.insertExperimentEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid InsertExperimentEvent") - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt index ee83bf28..634306c4 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventMerge.kt @@ -2,43 +2,58 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = InsertExperimentEventMerge.Builder::class) @NoAutoDetect -class InsertExperimentEventMerge -private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val datasetRecordId: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val additionalProperties: Map, +class InsertExperimentEventMerge private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val datasetRecordId: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _mergePaths: JsonField>>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -46,29 +61,31 @@ private constructor( private var hashCode: Int = 0 /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * 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(): JsonValue = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ fun expected(): JsonValue = expected @@ -76,22 +93,23 @@ private constructor( fun error(): JsonValue = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * 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.getNullable("scores") /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else 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.getNullable("metadata") @@ -99,16 +117,17 @@ private constructor( fun tags(): List? = tags.getNullable("tags") /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * 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.getNullable("metrics") /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * 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.getNullable("context") @@ -116,14 +135,14 @@ private constructor( fun spanAttributes(): SpanAttributes? = spanAttributes.getNullable("span_attributes") /** - * 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.getNullable("id") /** - * 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(): String? = datasetRecordId.getNullable("dataset_record_id") @@ -131,157 +150,201 @@ private constructor( fun created(): OffsetDateTime? = created.getNullable("created") /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ fun _objectDelete(): Boolean? = _objectDelete.getNullable("_object_delete") /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * 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(): List>? = _mergePaths.getNullable("_merge_paths") /** - * 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() = input + @JsonProperty("input") + @ExcludeMissing + fun _input() = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - @JsonProperty("output") @ExcludeMissing fun _output() = output + @JsonProperty("output") + @ExcludeMissing + fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error + @JsonProperty("error") + @ExcludeMissing + fun _error() = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores() = scores /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics() = metrics /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - @JsonProperty("context") @ExcludeMissing fun _context() = context + @JsonProperty("context") + @ExcludeMissing + fun _context() = context /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") + @ExcludeMissing + fun _spanAttributes() = spanAttributes /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId + @JsonProperty("dataset_record_id") + @ExcludeMissing + fun _datasetRecordId() = datasetRecordId /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") + @ExcludeMissing + fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge() = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + @JsonProperty("_merge_paths") + @ExcludeMissing + fun __mergePaths() = _mergePaths @JsonAnyGetter @ExcludeMissing @@ -289,81 +352,79 @@ private constructor( fun validate(): InsertExperimentEventMerge = apply { if (!validated) { - input() - output() - expected() - error() - scores()?.validate() - metadata()?.validate() - tags() - metrics()?.validate() - context()?.validate() - spanAttributes()?.validate() - id() - datasetRecordId() - created() - _objectDelete() - _isMerge() - _mergePaths() - validated = true + input() + output() + expected() + error() + scores()?.validate() + metadata()?.validate() + tags() + metrics()?.validate() + context()?.validate() + spanAttributes()?.validate() + id() + datasetRecordId() + created() + _objectDelete() + _isMerge() + _mergePaths() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertExperimentEventMerge && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertExperimentEventMerge && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.datasetRecordId == other.datasetRecordId && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._mergePaths == other._mergePaths && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _mergePaths, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "InsertExperimentEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + override fun toString() = "InsertExperimentEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" companion object { @@ -411,86 +472,102 @@ private constructor( } /** - * 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(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { + this.input = input + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = apply { + this.output = output + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** The error that occurred, if any. */ @JsonProperty("error") @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = apply { + this.error = error + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = apply { + this.scores = scores + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -498,43 +575,50 @@ private constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = apply { + this.metrics = metrics + } /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Context) = context(JsonField.of(context)) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = apply { + this.context = context + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -544,27 +628,30 @@ private constructor( } /** - * 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 */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String) = - datasetRecordId(JsonField.of(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String) = datasetRecordId(JsonField.of(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * 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 @@ -578,17 +665,19 @@ private constructor( /** The timestamp the experiment event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * 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 @@ -597,64 +686,70 @@ private constructor( } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = apply { + this._isMerge = _isMerge + } /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * 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 @@ -676,41 +771,41 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): InsertExperimentEventMerge = - InsertExperimentEventMerge( - input, - output, - expected, - error, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertExperimentEventMerge = InsertExperimentEventMerge( + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _mergePaths.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } /** - * 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 */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, + class Context private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -732,10 +827,14 @@ private constructor( fun _callerFunctionname() = callerFunctionname /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename() = callerFilename /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -743,42 +842,40 @@ private constructor( fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { @@ -800,8 +897,7 @@ private constructor( } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -811,8 +907,7 @@ private constructor( } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -845,29 +940,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun build(): Context = Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else 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 */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -879,25 +970,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" @@ -934,20 +1026,20 @@ 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 */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, + class Metrics private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -955,26 +1047,26 @@ private constructor( private var hashCode: Int = 0 /** - * 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(): Double? = start.getNullable("start") /** - * 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(): Double? = 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(): Long? = promptTokens.getNullable("prompt_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) */ fun completionTokens(): Long? = completionTokens.getNullable("completion_tokens") @@ -982,33 +1074,41 @@ private constructor( fun tokens(): Long? = tokens.getNullable("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 */ - @JsonProperty("start") @ExcludeMissing fun _start() = start + @JsonProperty("start") + @ExcludeMissing + fun _start() = start /** - * 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() = end + @JsonProperty("end") + @ExcludeMissing + fun _end() = end /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens() = promptTokens /** - * 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() = completionTokens /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -1016,48 +1116,46 @@ private constructor( fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { @@ -1083,42 +1181,46 @@ private constructor( } /** - * 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.of(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 */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = apply { + this.start = start + } /** - * 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.of(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 */ @JsonProperty("end") @ExcludeMissing - 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.of(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) */ @JsonProperty("prompt_tokens") @ExcludeMissing @@ -1127,15 +1229,14 @@ private constructor( } /** - * 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.of(completionTokens)) + fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing @@ -1149,7 +1250,9 @@ private constructor( /** The total number of tokens in the input and output of the experiment event. */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = apply { + this.tokens = tokens + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1165,33 +1268,30 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun build(): Metrics = Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * 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 */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { + class Scores private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1203,25 +1303,26 @@ private constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" @@ -1260,12 +1361,7 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { + class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1278,10 +1374,14 @@ private constructor( fun type(): Type? = type.getNullable("type") /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1289,39 +1389,37 @@ private constructor( fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1346,7 +1444,9 @@ private constructor( /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - 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.of(type)) @@ -1354,7 +1454,9 @@ private constructor( /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1370,28 +1472,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): SpanAttributes = SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1434,27 +1533,25 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt index 00fb6d90..1d49d138 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplace.kt @@ -2,43 +2,58 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = InsertExperimentEventReplace.Builder::class) @NoAutoDetect -class InsertExperimentEventReplace -private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val datasetRecordId: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, +class InsertExperimentEventReplace private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val datasetRecordId: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _parentId: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -46,29 +61,31 @@ private constructor( private var hashCode: Int = 0 /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * 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(): JsonValue = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ fun expected(): JsonValue = expected @@ -76,22 +93,23 @@ private constructor( fun error(): JsonValue = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * 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.getNullable("scores") /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else 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.getNullable("metadata") @@ -99,16 +117,17 @@ private constructor( fun tags(): List? = tags.getNullable("tags") /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * 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.getNullable("metrics") /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * 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.getNullable("context") @@ -116,14 +135,14 @@ private constructor( fun spanAttributes(): SpanAttributes? = spanAttributes.getNullable("span_attributes") /** - * 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.getNullable("id") /** - * 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(): String? = datasetRecordId.getNullable("dataset_record_id") @@ -131,155 +150,199 @@ private constructor( fun created(): OffsetDateTime? = created.getNullable("created") /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ fun _objectDelete(): Boolean? = _objectDelete.getNullable("_object_delete") /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Boolean? = _isMerge.getNullable("_is_merge") /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ fun _parentId(): String? = _parentId.getNullable("_parent_id") /** - * The arguments that uniquely define a test case (an arbitrary, JSON serializable object). - * Later on, Braintrust will use the `input` to know whether two test cases are the same between - * experiments, so they should not contain experiment-specific state. A simple rule of thumb is - * that if you run the same experiment twice, the `input` should be identical + * The arguments that uniquely define a test case (an arbitrary, JSON serializable + * object). Later on, Braintrust will use the `input` to know whether two test + * cases are the same between experiments, so they should not contain + * experiment-specific state. A simple rule of thumb is that if you run the same + * experiment twice, the `input` should be identical */ - @JsonProperty("input") @ExcludeMissing fun _input() = input + @JsonProperty("input") + @ExcludeMissing + fun _input() = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ - @JsonProperty("output") @ExcludeMissing fun _output() = output + @JsonProperty("output") + @ExcludeMissing + fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate your experiments while - * digging into analyses. However, we may later use these values to re-score outputs or - * fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error + @JsonProperty("error") + @ExcludeMissing + fun _error() = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare experiments */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores() = scores /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics() = metrics /** - * Context is additional information about the code that produced the experiment event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ - @JsonProperty("context") @ExcludeMissing fun _context() = context + @JsonProperty("context") + @ExcludeMissing + fun _context() = context /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") + @ExcludeMissing + fun _spanAttributes() = spanAttributes /** - * A unique identifier for the experiment event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the experiment event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - @JsonProperty("dataset_record_id") @ExcludeMissing fun _datasetRecordId() = datasetRecordId + @JsonProperty("dataset_record_id") + @ExcludeMissing + fun _datasetRecordId() = datasetRecordId /** The timestamp the experiment event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not show - * up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") + @ExcludeMissing + fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge() = _isMerge /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + @JsonProperty("_parent_id") + @ExcludeMissing + fun __parentId() = _parentId @JsonAnyGetter @ExcludeMissing @@ -287,81 +350,79 @@ private constructor( fun validate(): InsertExperimentEventReplace = apply { if (!validated) { - input() - output() - expected() - error() - scores()?.validate() - metadata()?.validate() - tags() - metrics()?.validate() - context()?.validate() - spanAttributes()?.validate() - id() - datasetRecordId() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true + input() + output() + expected() + error() + scores()?.validate() + metadata()?.validate() + tags() + metrics()?.validate() + context()?.validate() + spanAttributes()?.validate() + id() + datasetRecordId() + created() + _objectDelete() + _isMerge() + _parentId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertExperimentEventReplace && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.datasetRecordId == other.datasetRecordId && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertExperimentEventReplace && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.datasetRecordId == other.datasetRecordId && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._parentId == other._parentId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "InsertExperimentEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" + override fun toString() = "InsertExperimentEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, datasetRecordId=$datasetRecordId, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" companion object { @@ -409,86 +470,102 @@ private constructor( } /** - * 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(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { + this.input = input + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = apply { + this.output = output + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate your experiments - * while digging into analyses. However, we may later use these values to re-score outputs - * or fine-tune your models + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate your experiments while digging into analyses. + * However, we may later use these values to re-score outputs or fine-tune your + * models */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** The error that occurred, if any. */ @JsonProperty("error") @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = apply { + this.error = error + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare experiments + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare experiments */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = apply { + this.scores = scores + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -496,43 +573,50 @@ private constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * experiment event. Use "start" and "end" to track the time span over which the experiment - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the experiment event. Use "start" and "end" to track the time span over + * which the experiment event was produced */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = apply { + this.metrics = metrics + } /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ fun context(context: Context) = context(JsonField.of(context)) /** - * Context is additional information about the code that produced the experiment event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the experiment event + * Context is additional information about the code that produced the experiment + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the + * experiment event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = apply { + this.context = context + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -542,27 +626,30 @@ private constructor( } /** - * 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 */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * If the experiment is associated to a dataset, this is the event-level dataset id + * this experiment event is tied to */ - fun datasetRecordId(datasetRecordId: String) = - datasetRecordId(JsonField.of(datasetRecordId)) + fun datasetRecordId(datasetRecordId: String) = datasetRecordId(JsonField.of(datasetRecordId)) /** - * If the experiment is associated to a dataset, this is the event-level dataset id this - * experiment event is tied to + * 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 @@ -576,17 +663,19 @@ private constructor( /** The timestamp the experiment event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events + * will not show up in subsequent fetches for this experiment */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) /** - * Pass `_object_delete=true` to mark the experiment event deleted. Deleted events will not - * show up in subsequent fetches for this experiment + * 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 @@ -595,66 +684,74 @@ private constructor( } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = apply { + this._isMerge = _isMerge + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ @JsonProperty("_parent_id") @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun _parentId(_parentId: JsonField) = apply { + this._parentId = _parentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -670,41 +767,41 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): InsertExperimentEventReplace = - InsertExperimentEventReplace( - input, - output, - expected, - error, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - datasetRecordId, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertExperimentEventReplace = InsertExperimentEventReplace( + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + datasetRecordId, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties.toUnmodifiable(), + ) } /** - * 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 */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, + class Context private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -726,10 +823,14 @@ private constructor( fun _callerFunctionname() = callerFunctionname /** Name of the file in code where the experiment event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename() = callerFilename /** Line of code where the experiment event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -737,42 +838,40 @@ private constructor( fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { @@ -794,8 +893,7 @@ private constructor( } /** The function in code which created the experiment event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the experiment event */ @JsonProperty("caller_functionname") @@ -805,8 +903,7 @@ private constructor( } /** Name of the file in code where the experiment event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the experiment event was created */ @JsonProperty("caller_filename") @@ -839,29 +936,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun build(): Context = Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else 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 */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -873,25 +966,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" @@ -928,20 +1022,20 @@ 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 */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, + class Metrics private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -949,26 +1043,26 @@ private constructor( private var hashCode: Int = 0 /** - * 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(): Double? = start.getNullable("start") /** - * 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(): Double? = 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(): Long? = promptTokens.getNullable("prompt_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) */ fun completionTokens(): Long? = completionTokens.getNullable("completion_tokens") @@ -976,33 +1070,41 @@ private constructor( fun tokens(): Long? = tokens.getNullable("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 */ - @JsonProperty("start") @ExcludeMissing fun _start() = start + @JsonProperty("start") + @ExcludeMissing + fun _start() = start /** - * 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() = end + @JsonProperty("end") + @ExcludeMissing + fun _end() = end /** - * The number of tokens in the prompt used to generate the experiment event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the experiment event (only + * set if this is an LLM span) */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens() = promptTokens /** - * 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() = completionTokens /** The total number of tokens in the input and output of the experiment event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -1010,48 +1112,46 @@ private constructor( fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { @@ -1077,42 +1177,46 @@ private constructor( } /** - * 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.of(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 */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = apply { + this.start = start + } /** - * 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.of(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 */ @JsonProperty("end") @ExcludeMissing - 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.of(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) */ @JsonProperty("prompt_tokens") @ExcludeMissing @@ -1121,15 +1225,14 @@ private constructor( } /** - * 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.of(completionTokens)) + fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing @@ -1143,7 +1246,9 @@ private constructor( /** The total number of tokens in the input and output of the experiment event. */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = apply { + this.tokens = tokens + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1159,33 +1264,30 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun build(): Metrics = Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * 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 */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { + class Scores private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1197,25 +1299,26 @@ private constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" @@ -1254,12 +1357,7 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { + class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1272,10 +1370,14 @@ private constructor( fun type(): Type? = type.getNullable("type") /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1283,39 +1385,37 @@ private constructor( fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1340,7 +1440,9 @@ private constructor( /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - 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.of(type)) @@ -1348,7 +1450,9 @@ private constructor( /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1364,28 +1468,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): SpanAttributes = SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1428,27 +1529,25 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequest.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequest.kt deleted file mode 100755 index 946efeec..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequest.kt +++ /dev/null @@ -1,259 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(builder = InsertExperimentEventRequest.Builder::class) -@NoAutoDetect -class InsertExperimentEventRequest -private constructor( - private val events: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of experiment events to insert */ - fun events(): List = events.getRequired("events") - - /** A list of experiment events to insert */ - @JsonProperty("events") @ExcludeMissing fun _events() = events - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertExperimentEventRequest = apply { - if (!validated) { - events() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertExperimentEventRequest && - this.events == other.events && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode - } - - override fun toString() = - "InsertExperimentEventRequest{events=$events, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var events: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(insertExperimentEventRequest: InsertExperimentEventRequest) = apply { - this.events = insertExperimentEventRequest.events - additionalProperties(insertExperimentEventRequest.additionalProperties) - } - - /** A list of experiment events to insert */ - fun events(events: List) = events(JsonField.of(events)) - - /** A list of experiment events to insert */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InsertExperimentEventRequest = - InsertExperimentEventRequest( - events.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } - - @JsonDeserialize(using = Event.Deserializer::class) - @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertExperimentEventReplace: InsertExperimentEventReplace? = null, - private val insertExperimentEventMerge: InsertExperimentEventMerge? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun insertExperimentEventReplace(): InsertExperimentEventReplace? = - insertExperimentEventReplace - - fun insertExperimentEventMerge(): InsertExperimentEventMerge? = insertExperimentEventMerge - - fun isInsertExperimentEventReplace(): Boolean = insertExperimentEventReplace != null - - fun isInsertExperimentEventMerge(): Boolean = insertExperimentEventMerge != null - - fun asInsertExperimentEventReplace(): InsertExperimentEventReplace = - insertExperimentEventReplace.getOrThrow("insertExperimentEventReplace") - - fun asInsertExperimentEventMerge(): InsertExperimentEventMerge = - insertExperimentEventMerge.getOrThrow("insertExperimentEventMerge") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - insertExperimentEventReplace != null -> - visitor.visitInsertExperimentEventReplace(insertExperimentEventReplace) - insertExperimentEventMerge != null -> - visitor.visitInsertExperimentEventMerge(insertExperimentEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): Event = apply { - if (!validated) { - if (insertExperimentEventReplace == null && insertExperimentEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertExperimentEventReplace?.validate() - insertExperimentEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.insertExperimentEventReplace == other.insertExperimentEventReplace && - this.insertExperimentEventMerge == other.insertExperimentEventMerge - } - - override fun hashCode(): Int { - return Objects.hash(insertExperimentEventReplace, insertExperimentEventMerge) - } - - override fun toString(): String { - return when { - insertExperimentEventReplace != null -> - "Event{insertExperimentEventReplace=$insertExperimentEventReplace}" - insertExperimentEventMerge != null -> - "Event{insertExperimentEventMerge=$insertExperimentEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } - } - - companion object { - - fun ofInsertExperimentEventReplace( - insertExperimentEventReplace: InsertExperimentEventReplace - ) = Event(insertExperimentEventReplace = insertExperimentEventReplace) - - fun ofInsertExperimentEventMerge( - insertExperimentEventMerge: InsertExperimentEventMerge - ) = Event(insertExperimentEventMerge = insertExperimentEventMerge) - } - - interface Visitor { - - fun visitInsertExperimentEventReplace( - insertExperimentEventReplace: InsertExperimentEventReplace - ): T - - fun visitInsertExperimentEventMerge( - insertExperimentEventMerge: InsertExperimentEventMerge - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") - } - } - - class Deserializer : BaseDeserializer(Event::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertExperimentEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Event(insertExperimentEventMerge = it, _json = json) - } - - return Event(_json = json) - } - } - - class Serializer : BaseSerializer(Event::class) { - - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertExperimentEventReplace != null -> - generator.writeObject(value.insertExperimentEventReplace) - value.insertExperimentEventMerge != null -> - generator.writeObject(value.insertExperimentEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt deleted file mode 100755 index e0372954..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEvent.kt +++ /dev/null @@ -1,153 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(using = InsertProjectLogsEvent.Deserializer::class) -@JsonSerialize(using = InsertProjectLogsEvent.Serializer::class) -class InsertProjectLogsEvent -private constructor( - private val insertProjectLogsEventReplace: InsertProjectLogsEventReplace? = null, - private val insertProjectLogsEventMerge: InsertProjectLogsEventMerge? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun insertProjectLogsEventReplace(): InsertProjectLogsEventReplace? = - insertProjectLogsEventReplace - - fun insertProjectLogsEventMerge(): InsertProjectLogsEventMerge? = insertProjectLogsEventMerge - - fun isInsertProjectLogsEventReplace(): Boolean = insertProjectLogsEventReplace != null - - fun isInsertProjectLogsEventMerge(): Boolean = insertProjectLogsEventMerge != null - - fun asInsertProjectLogsEventReplace(): InsertProjectLogsEventReplace = - insertProjectLogsEventReplace.getOrThrow("insertProjectLogsEventReplace") - - fun asInsertProjectLogsEventMerge(): InsertProjectLogsEventMerge = - insertProjectLogsEventMerge.getOrThrow("insertProjectLogsEventMerge") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - insertProjectLogsEventReplace != null -> - visitor.visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace) - insertProjectLogsEventMerge != null -> - visitor.visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): InsertProjectLogsEvent = apply { - if (!validated) { - if (insertProjectLogsEventReplace == null && insertProjectLogsEventMerge == null) { - throw BraintrustInvalidDataException("Unknown InsertProjectLogsEvent: $_json") - } - insertProjectLogsEventReplace?.validate() - insertProjectLogsEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertProjectLogsEvent && - this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && - this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge - } - - override fun hashCode(): Int { - return Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) - } - - override fun toString(): String { - return when { - insertProjectLogsEventReplace != null -> - "InsertProjectLogsEvent{insertProjectLogsEventReplace=$insertProjectLogsEventReplace}" - insertProjectLogsEventMerge != null -> - "InsertProjectLogsEvent{insertProjectLogsEventMerge=$insertProjectLogsEventMerge}" - _json != null -> "InsertProjectLogsEvent{_unknown=$_json}" - else -> throw IllegalStateException("Invalid InsertProjectLogsEvent") - } - } - - companion object { - - fun ofInsertProjectLogsEventReplace( - insertProjectLogsEventReplace: InsertProjectLogsEventReplace - ) = InsertProjectLogsEvent(insertProjectLogsEventReplace = insertProjectLogsEventReplace) - - fun ofInsertProjectLogsEventMerge( - insertProjectLogsEventMerge: InsertProjectLogsEventMerge - ) = InsertProjectLogsEvent(insertProjectLogsEventMerge = insertProjectLogsEventMerge) - } - - interface Visitor { - - fun visitInsertProjectLogsEventReplace( - insertProjectLogsEventReplace: InsertProjectLogsEventReplace - ): T - - fun visitInsertProjectLogsEventMerge( - insertProjectLogsEventMerge: InsertProjectLogsEventMerge - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown InsertProjectLogsEvent: $json") - } - } - - class Deserializer : BaseDeserializer(InsertProjectLogsEvent::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): InsertProjectLogsEvent { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return InsertProjectLogsEvent(insertProjectLogsEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return InsertProjectLogsEvent(insertProjectLogsEventMerge = it, _json = json) - } - - return InsertProjectLogsEvent(_json = json) - } - } - - class Serializer : BaseSerializer(InsertProjectLogsEvent::class) { - - override fun serialize( - value: InsertProjectLogsEvent, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertProjectLogsEventReplace != null -> - generator.writeObject(value.insertProjectLogsEventReplace) - value.insertProjectLogsEventMerge != null -> - generator.writeObject(value.insertProjectLogsEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid InsertProjectLogsEvent") - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt index 30b77d3c..4f587f7a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMerge.kt @@ -2,67 +2,85 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = InsertProjectLogsEventMerge.Builder::class) @NoAutoDetect -class InsertProjectLogsEventMerge -private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _mergePaths: JsonField>>, - private val additionalProperties: Map, +class InsertProjectLogsEventMerge private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _mergePaths: JsonField>>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - /** 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(): JsonValue = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ fun expected(): JsonValue = expected @@ -70,22 +88,23 @@ private constructor( fun error(): JsonValue = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * 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.getNullable("scores") /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else 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.getNullable("metadata") @@ -93,16 +112,17 @@ private constructor( fun tags(): List? = tags.getNullable("tags") /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * 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.getNullable("metrics") /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * 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.getNullable("context") @@ -110,8 +130,8 @@ private constructor( fun spanAttributes(): SpanAttributes? = spanAttributes.getNullable("span_attributes") /** - * 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.getNullable("id") @@ -119,146 +139,189 @@ private constructor( fun created(): OffsetDateTime? = created.getNullable("created") /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs + * 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(): Boolean? = _objectDelete.getNullable("_object_delete") /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Boolean = _isMerge.getRequired("_is_merge") /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * 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(): List>? = _mergePaths.getNullable("_merge_paths") - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") @ExcludeMissing fun _input() = input + /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). + */ + @JsonProperty("input") + @ExcludeMissing + fun _input() = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - @JsonProperty("output") @ExcludeMissing fun _output() = output + @JsonProperty("output") + @ExcludeMissing + fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error + @JsonProperty("error") + @ExcludeMissing + fun _error() = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores() = scores /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics() = metrics /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - @JsonProperty("context") @ExcludeMissing fun _context() = context + @JsonProperty("context") + @ExcludeMissing + fun _context() = context /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") + @ExcludeMissing + fun _spanAttributes() = spanAttributes /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") + @ExcludeMissing + fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge() = _isMerge /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be specified - * alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path is a list of - * field names. The deep merge will not descend below any of the specified merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": 10}, - * "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": true, - * "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, - * "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": {"a": {"q": - * 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this case, due to the - * merge paths, we have replaced `input.a` and `output`, but have still deep-merged `input` and - * `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ - @JsonProperty("_merge_paths") @ExcludeMissing fun __mergePaths() = _mergePaths + @JsonProperty("_merge_paths") + @ExcludeMissing + fun __mergePaths() = _mergePaths @JsonAnyGetter @ExcludeMissing @@ -266,78 +329,76 @@ private constructor( fun validate(): InsertProjectLogsEventMerge = apply { if (!validated) { - input() - output() - expected() - error() - scores()?.validate() - metadata()?.validate() - tags() - metrics()?.validate() - context()?.validate() - spanAttributes()?.validate() - id() - created() - _objectDelete() - _isMerge() - _mergePaths() - validated = true + input() + output() + expected() + error() + scores()?.validate() + metadata()?.validate() + tags() + metrics()?.validate() + context()?.validate() + spanAttributes()?.validate() + id() + created() + _objectDelete() + _isMerge() + _mergePaths() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertProjectLogsEventMerge && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._mergePaths == other._mergePaths && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertProjectLogsEventMerge && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._mergePaths == other._mergePaths && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _mergePaths, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _mergePaths, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "InsertProjectLogsEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" + override fun toString() = "InsertProjectLogsEventMerge{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _mergePaths=$_mergePaths, additionalProperties=$additionalProperties}" companion object { @@ -383,83 +444,98 @@ private constructor( } /** - * 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). */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { + this.input = input + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = apply { + this.output = output + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** The error that occurred, if any. */ @JsonProperty("error") @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = apply { + this.error = error + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = apply { + this.scores = scores + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -467,43 +543,50 @@ private constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = apply { + this.metrics = metrics + } /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Context) = context(JsonField.of(context)) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = apply { + this.context = context + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -513,16 +596,20 @@ private constructor( } /** - * 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 */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -530,17 +617,19 @@ private constructor( /** The timestamp the project logs event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * 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 @@ -549,64 +638,70 @@ private constructor( } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = apply { + this._isMerge = _isMerge + } /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. + * If we merge a new row as + * `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, + * the new row will be + * `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. + * In this case, due to the merge paths, we have replaced `input.a` and `output`, + * but have still deep-merged `input` and `input.c`. */ fun _mergePaths(_mergePaths: List>) = _mergePaths(JsonField.of(_mergePaths)) /** - * The `_merge_paths` field allows controlling the depth of the merge. It can only be - * specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, where each path - * is a list of field names. The deep merge will not descend below any of the specified - * merge paths. + * The `_merge_paths` field allows controlling the depth of the merge. It can only + * be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, + * where each path is a list of field names. The deep merge will not descend below + * any of the specified merge paths. * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": {"b": - * 10}, "c": {"d": 20}}, "output": {"a": 20}}`. If we merge a new row as `{"_is_merge": - * true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": - * 30}, "bar": "baz"}, "output": {"d": 40}}`, the new row will be `{"id": "foo": "input": - * {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. In this - * case, due to the merge paths, we have replaced `input.a` and `output`, but have still - * deep-merged `input` and `input.c`. + * 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 @@ -628,40 +723,40 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): InsertProjectLogsEventMerge = - InsertProjectLogsEventMerge( - input, - output, - expected, - error, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _mergePaths.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertProjectLogsEventMerge = InsertProjectLogsEventMerge( + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _mergePaths.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } /** - * 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 */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, + class Context private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -683,10 +778,14 @@ private constructor( fun _callerFunctionname() = callerFunctionname /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename() = callerFilename /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -694,42 +793,40 @@ private constructor( fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { @@ -751,8 +848,7 @@ private constructor( } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -762,8 +858,7 @@ private constructor( } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -796,29 +891,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun build(): Context = Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else 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 */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -830,25 +921,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" @@ -885,20 +977,20 @@ 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 */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, + class Metrics private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -906,26 +998,26 @@ private constructor( private var hashCode: Int = 0 /** - * 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(): Double? = start.getNullable("start") /** - * 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(): Double? = 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(): Long? = promptTokens.getNullable("prompt_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) */ fun completionTokens(): Long? = completionTokens.getNullable("completion_tokens") @@ -933,33 +1025,41 @@ private constructor( fun tokens(): Long? = tokens.getNullable("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 */ - @JsonProperty("start") @ExcludeMissing fun _start() = start + @JsonProperty("start") + @ExcludeMissing + fun _start() = start /** - * 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() = end + @JsonProperty("end") + @ExcludeMissing + fun _end() = end /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens() = promptTokens /** - * 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() = completionTokens /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -967,48 +1067,46 @@ private constructor( fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { @@ -1034,42 +1132,46 @@ private constructor( } /** - * 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.of(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 */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = apply { + this.start = start + } /** - * 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.of(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 */ @JsonProperty("end") @ExcludeMissing - 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.of(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) */ @JsonProperty("prompt_tokens") @ExcludeMissing @@ -1078,15 +1180,14 @@ private constructor( } /** - * 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.of(completionTokens)) + fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing @@ -1100,7 +1201,9 @@ private constructor( /** The total number of tokens in the input and output of the project logs event. */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = apply { + this.tokens = tokens + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1116,33 +1219,30 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun build(): Metrics = Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * 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. */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { + class Scores private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1154,25 +1254,26 @@ private constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" @@ -1211,12 +1312,7 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { + class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1229,10 +1325,14 @@ private constructor( fun type(): Type? = type.getNullable("type") /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1240,39 +1340,37 @@ private constructor( fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1297,7 +1395,9 @@ private constructor( /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - 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.of(type)) @@ -1305,7 +1405,9 @@ private constructor( /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1321,28 +1423,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): SpanAttributes = SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1385,27 +1484,25 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt index 139f1175..3416dd11 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplace.kt @@ -2,67 +2,85 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = InsertProjectLogsEventReplace.Builder::class) @NoAutoDetect -class InsertProjectLogsEventReplace -private constructor( - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanAttributes: JsonField, - private val id: JsonField, - private val created: JsonField, - private val _objectDelete: JsonField, - private val _isMerge: JsonField, - private val _parentId: JsonField, - private val additionalProperties: Map, +class InsertProjectLogsEventReplace private constructor( + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanAttributes: JsonField, + private val id: JsonField, + private val created: JsonField, + private val _objectDelete: JsonField, + private val _isMerge: JsonField, + private val _parentId: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false private var hashCode: Int = 0 - /** 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(): JsonValue = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ fun expected(): JsonValue = expected @@ -70,22 +88,23 @@ private constructor( fun error(): JsonValue = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * 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.getNullable("scores") /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else 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.getNullable("metadata") @@ -93,16 +112,17 @@ private constructor( fun tags(): List? = tags.getNullable("tags") /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * 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.getNullable("metrics") /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * 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.getNullable("context") @@ -110,8 +130,8 @@ private constructor( fun spanAttributes(): SpanAttributes? = spanAttributes.getNullable("span_attributes") /** - * 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.getNullable("id") @@ -119,144 +139,187 @@ private constructor( fun created(): OffsetDateTime? = created.getNullable("created") /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs + * 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(): Boolean? = _objectDelete.getNullable("_object_delete") /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(): Boolean? = _isMerge.getNullable("_is_merge") /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ fun _parentId(): String? = _parentId.getNullable("_parent_id") - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") @ExcludeMissing fun _input() = input + /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). + */ + @JsonProperty("input") + @ExcludeMissing + fun _input() = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - @JsonProperty("output") @ExcludeMissing fun _output() = output + @JsonProperty("output") + @ExcludeMissing + fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error + @JsonProperty("error") + @ExcludeMissing + fun _error() = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores() = scores /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics() = metrics /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - @JsonProperty("context") @ExcludeMissing fun _context() = context + @JsonProperty("context") + @ExcludeMissing + fun _context() = context /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") + @ExcludeMissing + fun _spanAttributes() = spanAttributes /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * A unique identifier for the project logs event. If you don't provide one, + * BrainTrust will generate one for you */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will not - * show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ - @JsonProperty("_object_delete") @ExcludeMissing fun __objectDelete() = _objectDelete + @JsonProperty("_object_delete") + @ExcludeMissing + fun __objectDelete() = _objectDelete /** - * The `_is_merge` field controls how the row is merged with any existing row with the same id - * in the DB. By default (or when set to `false`), the existing row is completely replaced by - * the new row. When set to `true`, the new row is deep-merged into the existing row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ - @JsonProperty("_is_merge") @ExcludeMissing fun __isMerge() = _isMerge + @JsonProperty("_is_merge") + @ExcludeMissing + fun __isMerge() = _isMerge /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot be - * specified alongside `_is_merge=true`. Tracking hierarchical relationships are important for - * tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the parent - * row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after - * foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the root span row - * `"abc"` will show up in the summary view. You can view the full trace hierarchy (in this - * case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ - @JsonProperty("_parent_id") @ExcludeMissing fun __parentId() = _parentId + @JsonProperty("_parent_id") + @ExcludeMissing + fun __parentId() = _parentId @JsonAnyGetter @ExcludeMissing @@ -264,78 +327,76 @@ private constructor( fun validate(): InsertProjectLogsEventReplace = apply { if (!validated) { - input() - output() - expected() - error() - scores()?.validate() - metadata()?.validate() - tags() - metrics()?.validate() - context()?.validate() - spanAttributes()?.validate() - id() - created() - _objectDelete() - _isMerge() - _parentId() - validated = true + input() + output() + expected() + error() + scores()?.validate() + metadata()?.validate() + tags() + metrics()?.validate() + context()?.validate() + spanAttributes()?.validate() + id() + created() + _objectDelete() + _isMerge() + _parentId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertProjectLogsEventReplace && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanAttributes == other.spanAttributes && - this.id == other.id && - this.created == other.created && - this._objectDelete == other._objectDelete && - this._isMerge == other._isMerge && - this._parentId == other._parentId && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InsertProjectLogsEventReplace && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanAttributes == other.spanAttributes && + this.id == other.id && + this.created == other.created && + this._objectDelete == other._objectDelete && + this._isMerge == other._isMerge && + this._parentId == other._parentId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "InsertProjectLogsEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" + override fun toString() = "InsertProjectLogsEventReplace{input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanAttributes=$spanAttributes, id=$id, created=$created, _objectDelete=$_objectDelete, _isMerge=$_isMerge, _parentId=$_parentId, additionalProperties=$additionalProperties}" companion object { @@ -381,83 +442,98 @@ private constructor( } /** - * 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). */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { + this.input = input + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = apply { + this.output = output + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** The error that occurred, if any. */ @JsonProperty("error") @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = apply { + this.error = error + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = apply { + this.scores = scores + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -465,43 +541,50 @@ private constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = apply { + this.metrics = metrics + } /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Context) = context(JsonField.of(context)) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = apply { + this.context = context + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -511,16 +594,20 @@ private constructor( } /** - * 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 */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** The timestamp the project logs event was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -528,17 +615,19 @@ private constructor( /** The timestamp the project logs event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * Pass `_object_delete=true` to mark the project logs event deleted. Deleted + * events will not show up in subsequent fetches for this project logs */ fun _objectDelete(_objectDelete: Boolean) = _objectDelete(JsonField.of(_objectDelete)) /** - * Pass `_object_delete=true` to mark the project logs event deleted. Deleted events will - * not show up in subsequent fetches for this project logs + * 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 @@ -547,66 +636,74 @@ private constructor( } /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ fun _isMerge(_isMerge: Boolean) = _isMerge(JsonField.of(_isMerge)) /** - * The `_is_merge` field controls how the row is merged with any existing row with the same - * id in the DB. By default (or when set to `false`), the existing row is completely - * replaced by the new row. When set to `true`, the new row is deep-merged into the existing - * row + * The `_is_merge` field controls how the row is merged with any existing row with + * the same id in the DB. By default (or when set to `false`), the existing row is + * completely replaced by the new row. When set to `true`, the new row is + * deep-merged into the existing row * - * For example, say there is an existing row in the DB `{"id": "foo", "input": {"a": 5, "b": - * 10}}`. If we merge a new row as `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": - * 20}}`, the new row will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we - * replace the new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be + * For example, say there is an existing row in the DB + * `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as + * `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row + * will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the + * new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be * `{"id": "foo", "input": {"b": 11, "c": 20}}` */ @JsonProperty("_is_merge") @ExcludeMissing - fun _isMerge(_isMerge: JsonField) = apply { this._isMerge = _isMerge } + fun _isMerge(_isMerge: JsonField) = apply { + this._isMerge = _isMerge + } /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ fun _parentId(_parentId: String) = _parentId(JsonField.of(_parentId)) /** - * Use the `_parent_id` field to create this row as a subspan of an existing row. It cannot - * be specified alongside `_is_merge=true`. Tracking hierarchical relationships are - * important for tracing (see the [guide](https://www.braintrust.dev/docs/guides/tracing) - * for full details). + * Use the `_parent_id` field to create this row as a subspan of an existing row. + * It cannot be specified alongside `_is_merge=true`. Tracking hierarchical + * relationships are important for tracing (see the + * [guide](https://www.braintrust.dev/docs/guides/tracing) for full details). * - * For example, say we have logged a row `{"id": "abc", "input": "foo", "output": "bar", - * "expected": "boo", "scores": {"correctness": 0.33}}`. We can create a sub-span of the - * parent row by logging `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What - * comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. In the webapp, only the - * root span row `"abc"` will show up in the summary view. You can view the full trace - * hierarchy (in this case, the `"llm_call"` row) by clicking on the "abc" row. + * For example, say we have logged a row + * `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. + * We can create a sub-span of the parent row by logging + * `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. + * In the webapp, only the root span row `"abc"` will show up in the summary view. + * You can view the full trace hierarchy (in this case, the `"llm_call"` row) by + * clicking on the "abc" row. */ @JsonProperty("_parent_id") @ExcludeMissing - fun _parentId(_parentId: JsonField) = apply { this._parentId = _parentId } + fun _parentId(_parentId: JsonField) = apply { + this._parentId = _parentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -622,40 +719,40 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): InsertProjectLogsEventReplace = - InsertProjectLogsEventReplace( - input, - output, - expected, - error, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanAttributes, - id, - created, - _objectDelete, - _isMerge, - _parentId, - additionalProperties.toUnmodifiable(), - ) + fun build(): InsertProjectLogsEventReplace = InsertProjectLogsEventReplace( + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanAttributes, + id, + created, + _objectDelete, + _isMerge, + _parentId, + additionalProperties.toUnmodifiable(), + ) } /** - * 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 */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, + class Context private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -677,10 +774,14 @@ private constructor( fun _callerFunctionname() = callerFunctionname /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename() = callerFilename /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -688,42 +789,40 @@ private constructor( fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { @@ -745,8 +844,7 @@ private constructor( } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -756,8 +854,7 @@ private constructor( } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -790,29 +887,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun build(): Context = Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else 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 */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -824,25 +917,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" @@ -879,20 +973,20 @@ 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 */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, + class Metrics private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -900,26 +994,26 @@ private constructor( private var hashCode: Int = 0 /** - * 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(): Double? = start.getNullable("start") /** - * 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(): Double? = 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(): Long? = promptTokens.getNullable("prompt_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) */ fun completionTokens(): Long? = completionTokens.getNullable("completion_tokens") @@ -927,33 +1021,41 @@ private constructor( fun tokens(): Long? = tokens.getNullable("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 */ - @JsonProperty("start") @ExcludeMissing fun _start() = start + @JsonProperty("start") + @ExcludeMissing + fun _start() = start /** - * 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() = end + @JsonProperty("end") + @ExcludeMissing + fun _end() = end /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens() = promptTokens /** - * 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() = completionTokens /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -961,48 +1063,46 @@ private constructor( fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { @@ -1028,42 +1128,46 @@ private constructor( } /** - * 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.of(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 */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = apply { + this.start = start + } /** - * 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.of(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 */ @JsonProperty("end") @ExcludeMissing - 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.of(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) */ @JsonProperty("prompt_tokens") @ExcludeMissing @@ -1072,15 +1176,14 @@ private constructor( } /** - * 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.of(completionTokens)) + fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing @@ -1094,7 +1197,9 @@ private constructor( /** The total number of tokens in the input and output of the project logs event. */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = apply { + this.tokens = tokens + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1110,33 +1215,30 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun build(): Metrics = Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * 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. */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { + class Scores private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1148,25 +1250,26 @@ private constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" @@ -1205,12 +1308,7 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { + class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1223,10 +1321,14 @@ private constructor( fun type(): Type? = type.getNullable("type") /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1234,39 +1336,37 @@ private constructor( fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1291,7 +1391,9 @@ private constructor( /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - 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.of(type)) @@ -1299,7 +1401,9 @@ private constructor( /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1315,28 +1419,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): SpanAttributes = SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1379,27 +1480,25 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequest.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequest.kt deleted file mode 100755 index d7198abf..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequest.kt +++ /dev/null @@ -1,262 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(builder = InsertProjectLogsEventRequest.Builder::class) -@NoAutoDetect -class InsertProjectLogsEventRequest -private constructor( - private val events: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of project logs events to insert */ - fun events(): List = events.getRequired("events") - - /** A list of project logs events to insert */ - @JsonProperty("events") @ExcludeMissing fun _events() = events - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InsertProjectLogsEventRequest = apply { - if (!validated) { - events() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InsertProjectLogsEventRequest && - this.events == other.events && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode - } - - override fun toString() = - "InsertProjectLogsEventRequest{events=$events, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var events: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(insertProjectLogsEventRequest: InsertProjectLogsEventRequest) = apply { - this.events = insertProjectLogsEventRequest.events - additionalProperties(insertProjectLogsEventRequest.additionalProperties) - } - - /** A list of project logs events to insert */ - fun events(events: List) = events(JsonField.of(events)) - - /** A list of project logs events to insert */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InsertProjectLogsEventRequest = - InsertProjectLogsEventRequest( - events.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } - - @JsonDeserialize(using = Event.Deserializer::class) - @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertProjectLogsEventReplace: InsertProjectLogsEventReplace? = null, - private val insertProjectLogsEventMerge: InsertProjectLogsEventMerge? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun insertProjectLogsEventReplace(): InsertProjectLogsEventReplace? = - insertProjectLogsEventReplace - - fun insertProjectLogsEventMerge(): InsertProjectLogsEventMerge? = - insertProjectLogsEventMerge - - fun isInsertProjectLogsEventReplace(): Boolean = insertProjectLogsEventReplace != null - - fun isInsertProjectLogsEventMerge(): Boolean = insertProjectLogsEventMerge != null - - fun asInsertProjectLogsEventReplace(): InsertProjectLogsEventReplace = - insertProjectLogsEventReplace.getOrThrow("insertProjectLogsEventReplace") - - fun asInsertProjectLogsEventMerge(): InsertProjectLogsEventMerge = - insertProjectLogsEventMerge.getOrThrow("insertProjectLogsEventMerge") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - insertProjectLogsEventReplace != null -> - visitor.visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace) - insertProjectLogsEventMerge != null -> - visitor.visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge) - else -> visitor.unknown(_json) - } - } - - fun validate(): Event = apply { - if (!validated) { - if (insertProjectLogsEventReplace == null && insertProjectLogsEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertProjectLogsEventReplace?.validate() - insertProjectLogsEventMerge?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && - this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge - } - - override fun hashCode(): Int { - return Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) - } - - override fun toString(): String { - return when { - insertProjectLogsEventReplace != null -> - "Event{insertProjectLogsEventReplace=$insertProjectLogsEventReplace}" - insertProjectLogsEventMerge != null -> - "Event{insertProjectLogsEventMerge=$insertProjectLogsEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } - } - - companion object { - - fun ofInsertProjectLogsEventReplace( - insertProjectLogsEventReplace: InsertProjectLogsEventReplace - ) = Event(insertProjectLogsEventReplace = insertProjectLogsEventReplace) - - fun ofInsertProjectLogsEventMerge( - insertProjectLogsEventMerge: InsertProjectLogsEventMerge - ) = Event(insertProjectLogsEventMerge = insertProjectLogsEventMerge) - } - - interface Visitor { - - fun visitInsertProjectLogsEventReplace( - insertProjectLogsEventReplace: InsertProjectLogsEventReplace - ): T - - fun visitInsertProjectLogsEventMerge( - insertProjectLogsEventMerge: InsertProjectLogsEventMerge - ): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") - } - } - - class Deserializer : BaseDeserializer(Event::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertProjectLogsEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertProjectLogsEventMerge = it, _json = json) - } - - return Event(_json = json) - } - } - - class Serializer : BaseSerializer(Event::class) { - - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertProjectLogsEventReplace != null -> - generator.writeObject(value.insertProjectLogsEventReplace) - value.insertProjectLogsEventMerge != null -> - generator.writeObject(value.insertProjectLogsEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt index fe0a1ffc..5927f535 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/MetricSummary.kt @@ -2,30 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** Summary of a metric's performance */ @JsonDeserialize(builder = MetricSummary.Builder::class) @NoAutoDetect -class MetricSummary -private constructor( - private val name: JsonField, - private val metric: JsonField, - private val unit: JsonField, - private val diff: JsonField, - private val improvements: JsonField, - private val regressions: JsonField, - private val additionalProperties: Map, +class MetricSummary private constructor( + private val name: JsonField, + private val metric: JsonField, + private val unit: JsonField, + private val diff: JsonField, + private val improvements: JsonField, + private val regressions: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -51,22 +70,34 @@ private constructor( fun regressions(): Long = regressions.getRequired("regressions") /** Name of the metric */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Average metric across all examples */ - @JsonProperty("metric") @ExcludeMissing fun _metric() = metric + @JsonProperty("metric") + @ExcludeMissing + fun _metric() = metric /** Unit label for the metric */ - @JsonProperty("unit") @ExcludeMissing fun _unit() = unit + @JsonProperty("unit") + @ExcludeMissing + fun _unit() = unit /** Difference in metric between the current and comparison experiment */ - @JsonProperty("diff") @ExcludeMissing fun _diff() = diff + @JsonProperty("diff") + @ExcludeMissing + fun _diff() = diff /** Number of improvements in the metric */ - @JsonProperty("improvements") @ExcludeMissing fun _improvements() = improvements + @JsonProperty("improvements") + @ExcludeMissing + fun _improvements() = improvements /** Number of regressions in the metric */ - @JsonProperty("regressions") @ExcludeMissing fun _regressions() = regressions + @JsonProperty("regressions") + @ExcludeMissing + fun _regressions() = regressions @JsonAnyGetter @ExcludeMissing @@ -74,51 +105,49 @@ private constructor( fun validate(): MetricSummary = apply { if (!validated) { - name() - metric() - unit() - diff() - improvements() - regressions() - validated = true + name() + metric() + unit() + diff() + improvements() + regressions() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MetricSummary && - this.name == other.name && - this.metric == other.metric && - this.unit == other.unit && - this.diff == other.diff && - this.improvements == other.improvements && - this.regressions == other.regressions && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is MetricSummary && + this.name == other.name && + this.metric == other.metric && + this.unit == other.unit && + this.diff == other.diff && + this.improvements == other.improvements && + this.regressions == other.regressions && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - metric, - unit, - diff, - improvements, - regressions, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + metric, + unit, + diff, + improvements, + regressions, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "MetricSummary{name=$name, metric=$metric, unit=$unit, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" + override fun toString() = "MetricSummary{name=$name, metric=$metric, unit=$unit, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" companion object { @@ -151,7 +180,9 @@ private constructor( /** Name of the metric */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } /** Average metric across all examples */ fun metric(metric: Double) = metric(JsonField.of(metric)) @@ -159,7 +190,9 @@ private constructor( /** Average metric across all examples */ @JsonProperty("metric") @ExcludeMissing - fun metric(metric: JsonField) = apply { this.metric = metric } + fun metric(metric: JsonField) = apply { + this.metric = metric + } /** Unit label for the metric */ fun unit(unit: String) = unit(JsonField.of(unit)) @@ -167,7 +200,9 @@ private constructor( /** Unit label for the metric */ @JsonProperty("unit") @ExcludeMissing - 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)) @@ -175,7 +210,9 @@ private constructor( /** Difference in metric between the current and comparison experiment */ @JsonProperty("diff") @ExcludeMissing - fun diff(diff: JsonField) = apply { this.diff = diff } + fun diff(diff: JsonField) = apply { + this.diff = diff + } /** Number of improvements in the metric */ fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) @@ -183,7 +220,9 @@ private constructor( /** Number of improvements in the metric */ @JsonProperty("improvements") @ExcludeMissing - fun improvements(improvements: JsonField) = apply { this.improvements = improvements } + fun improvements(improvements: JsonField) = apply { + this.improvements = improvements + } /** Number of regressions in the metric */ fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) @@ -191,7 +230,9 @@ private constructor( /** Number of regressions in the metric */ @JsonProperty("regressions") @ExcludeMissing - fun regressions(regressions: JsonField) = apply { this.regressions = regressions } + fun regressions(regressions: JsonField) = apply { + this.regressions = regressions + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -207,15 +248,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): MetricSummary = - MetricSummary( - name, - metric, - unit, - diff, - improvements, - regressions, - additionalProperties.toUnmodifiable(), - ) + fun build(): MetricSummary = MetricSummary( + name, + metric, + unit, + diff, + improvements, + regressions, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecret.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecret.kt index d6dccc5f..8a83e428 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecret.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecret.kt @@ -2,31 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = OrgSecret.Builder::class) @NoAutoDetect -class OrgSecret -private constructor( - private val id: JsonField, - private val created: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val type: JsonField, - private val metadata: JsonField, - private val previewSecret: JsonField, - private val additionalProperties: Map, +class OrgSecret private constructor( + private val id: JsonField, + private val created: JsonField, + private val orgId: JsonField, + private val name: JsonField, + private val type: JsonField, + private val metadata: JsonField, + private val previewSecret: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -52,22 +70,36 @@ private constructor( fun previewSecret(): String? = previewSecret.getNullable("preview_secret") /** Unique identifier for the org secret */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** Date of org secret creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId() = orgId /** Name of the org secret */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata - @JsonProperty("preview_secret") @ExcludeMissing fun _previewSecret() = previewSecret + @JsonProperty("preview_secret") + @ExcludeMissing + fun _previewSecret() = previewSecret @JsonAnyGetter @ExcludeMissing @@ -75,54 +107,52 @@ private constructor( fun validate(): OrgSecret = apply { if (!validated) { - id() - created() - orgId() - name() - type() - metadata()?.validate() - previewSecret() - validated = true + id() + created() + orgId() + name() + type() + metadata()?.validate() + previewSecret() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecret && - this.id == other.id && - this.created == other.created && - this.orgId == other.orgId && - this.name == other.name && - this.type == other.type && - this.metadata == other.metadata && - this.previewSecret == other.previewSecret && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OrgSecret && + this.id == other.id && + this.created == other.created && + this.orgId == other.orgId && + this.name == other.name && + this.type == other.type && + this.metadata == other.metadata && + this.previewSecret == other.previewSecret && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - created, - orgId, - name, - type, - metadata, - previewSecret, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + created, + orgId, + name, + type, + metadata, + previewSecret, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "OrgSecret{id=$id, created=$created, orgId=$orgId, name=$name, type=$type, metadata=$metadata, previewSecret=$previewSecret, additionalProperties=$additionalProperties}" + override fun toString() = "OrgSecret{id=$id, created=$created, orgId=$orgId, name=$name, type=$type, metadata=$metadata, previewSecret=$previewSecret, additionalProperties=$additionalProperties}" companion object { @@ -155,7 +185,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the org secret */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** Date of org secret creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -163,7 +197,9 @@ private constructor( /** Date of org secret creation */ @JsonProperty("created") @ExcludeMissing - 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.of(orgId)) @@ -171,7 +207,9 @@ private constructor( /** Unique identifier for the organization */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = apply { + this.orgId = orgId + } /** Name of the org secret */ fun name(name: String) = name(JsonField.of(name)) @@ -179,19 +217,25 @@ private constructor( /** Name of the org secret */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } fun type(type: String) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } fun previewSecret(previewSecret: String) = previewSecret(JsonField.of(previewSecret)) @@ -215,25 +259,21 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): OrgSecret = - OrgSecret( - id, - created, - orgId, - name, - type, - metadata, - previewSecret, - additionalProperties.toUnmodifiable(), - ) + fun build(): OrgSecret = OrgSecret( + id, + created, + orgId, + name, + type, + metadata, + previewSecret, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -245,25 +285,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretCreateParams.kt index 88f52ab7..c0ded690 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretCreateParams.kt @@ -2,27 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class OrgSecretCreateParams constructor( + private val name: String, + private val metadata: Metadata?, + private val orgName: String?, + private val secret: String?, + private val type: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class OrgSecretCreateParams -constructor( - private val name: String, - private val metadata: Metadata?, - private val orgName: String?, - private val secret: String?, - private val type: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -36,14 +59,14 @@ constructor( fun type(): String? = type internal fun getBody(): OrgSecretCreateBody { - return OrgSecretCreateBody( - name, - metadata, - orgName, - secret, - type, - additionalBodyProperties, - ) + return OrgSecretCreateBody( + name, + metadata, + orgName, + secret, + type, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -52,37 +75,42 @@ constructor( @JsonDeserialize(builder = OrgSecretCreateBody.Builder::class) @NoAutoDetect - class OrgSecretCreateBody - internal constructor( - private val name: String?, - private val metadata: Metadata?, - private val orgName: String?, - private val secret: String?, - private val type: String?, - private val additionalProperties: Map, + class OrgSecretCreateBody internal constructor( + private val name: String?, + private val metadata: Metadata?, + private val orgName: String?, + private val secret: String?, + private val type: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the org secret */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + @JsonProperty("metadata") + fun metadata(): 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 Org 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 Org Secret belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + @JsonProperty("org_name") + fun orgName(): String? = 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") fun secret(): String? = secret + @JsonProperty("secret") + fun secret(): String? = secret - @JsonProperty("type") fun type(): String? = type + @JsonProperty("type") + fun type(): String? = type @JsonAnyGetter @ExcludeMissing @@ -91,36 +119,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretCreateBody && - this.name == other.name && - this.metadata == other.metadata && - this.orgName == other.orgName && - this.secret == other.secret && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OrgSecretCreateBody && + this.name == other.name && + this.metadata == other.metadata && + this.orgName == other.orgName && + this.secret == other.secret && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - metadata, - orgName, - secret, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + metadata, + orgName, + secret, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "OrgSecretCreateBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "OrgSecretCreateBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -146,26 +172,39 @@ constructor( } /** Name of the org secret */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = 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 Org 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 Org Secret belongs in. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = 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. */ - @JsonProperty("secret") fun secret(secret: String) = apply { this.secret = secret } + @JsonProperty("secret") + fun secret(secret: String) = apply { + this.secret = secret + } - @JsonProperty("type") fun type(type: String) = apply { this.type = type } + @JsonProperty("type") + fun type(type: String) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -181,15 +220,16 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): OrgSecretCreateBody = - OrgSecretCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - metadata, - orgName, - secret, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): OrgSecretCreateBody = OrgSecretCreateBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + metadata, + orgName, + secret, + type, + additionalProperties.toUnmodifiable(), + ) } } @@ -200,36 +240,35 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretCreateParams && - this.name == other.name && - this.metadata == other.metadata && - this.orgName == other.orgName && - this.secret == other.secret && - this.type == other.type && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrgSecretCreateParams && + this.name == other.name && + this.metadata == other.metadata && + this.orgName == other.orgName && + this.secret == other.secret && + this.type == other.type && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - metadata, - orgName, - secret, - type, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + metadata, + orgName, + secret, + type, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "OrgSecretCreateParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "OrgSecretCreateParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -262,24 +301,34 @@ constructor( } /** Name of the org secret */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = 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 Org 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 Org Secret belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = 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) = apply { this.secret = secret } + fun secret(secret: String) = apply { + this.secret = secret + } - fun type(type: String) = apply { this.type = type } + fun type(type: String) = apply { + this.type = type + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -319,7 +368,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -330,30 +381,27 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): OrgSecretCreateParams = - OrgSecretCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - metadata, - orgName, - secret, - type, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): OrgSecretCreateParams = OrgSecretCreateParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + metadata, + orgName, + secret, + type, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var hashCode: Int = 0 @@ -364,18 +412,19 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretDeleteParams.kt index 02880990..ffd7330a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class OrgSecretDeleteParams -constructor( - private val orgSecretId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class OrgSecretDeleteParams constructor( + private val orgSecretId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun orgSecretId(): String = orgSecretId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> orgSecretId - else -> "" - } + return when (index) { + 0 -> orgSecretId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretDeleteParams && - this.orgSecretId == other.orgSecretId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrgSecretDeleteParams && + this.orgSecretId == other.orgSecretId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - orgSecretId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + orgSecretId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "OrgSecretDeleteParams{orgSecretId=$orgSecretId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "OrgSecretDeleteParams{orgSecretId=$orgSecretId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** OrgSecret id */ - fun orgSecretId(orgSecretId: String) = apply { this.orgSecretId = orgSecretId } + fun orgSecretId(orgSecretId: String) = apply { + this.orgSecretId = orgSecretId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): OrgSecretDeleteParams = - OrgSecretDeleteParams( - checkNotNull(orgSecretId) { "`orgSecretId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): OrgSecretDeleteParams = OrgSecretDeleteParams( + checkNotNull(orgSecretId) { + "`orgSecretId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListPage.kt index 52b9027f..2e71ff29 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListPage.kt @@ -2,101 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.OrgSecret import com.braintrustdata.api.services.blocking.OrgSecretService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class OrgSecretListPage -private constructor( - private val orgSecretService: OrgSecretService, - private val params: OrgSecretListParams, - private val response: Response, -) { +class OrgSecretListPage private constructor(private val orgSecretService: OrgSecretService, private val params: OrgSecretListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretListPage && - this.orgSecretService == other.orgSecretService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is OrgSecretListPage && + this.orgSecretService == other.orgSecretService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - orgSecretService, - params, - response, - ) + return Objects.hash( + orgSecretService, + params, + response, + ) } - override fun toString() = - "OrgSecretListPage{orgSecretService=$orgSecretService, params=$params, response=$response}" + override fun toString() = "OrgSecretListPage{orgSecretService=$orgSecretService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): OrgSecretListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - OrgSecretListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - OrgSecretListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + OrgSecretListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + OrgSecretListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): OrgSecretListPage? { - return getNextPageParams()?.let { orgSecretService.list(it) } + return getNextPageParams()?.let { + orgSecretService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - orgSecretService: OrgSecretService, - params: OrgSecretListParams, - response: Response - ) = - OrgSecretListPage( - orgSecretService, - params, - response, - ) + fun of(orgSecretService: OrgSecretService, params: OrgSecretListParams, response: Response) = OrgSecretListPage( + orgSecretService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -104,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "OrgSecretListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "OrgSecretListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -157,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: OrgSecretListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: OrgSecretListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListPageAsync.kt index f936ea67..f3ab2544 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListPageAsync.kt @@ -2,103 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.OrgSecretServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.OrgSecret +import com.braintrustdata.api.services.async.OrgSecretServiceAsync -class OrgSecretListPageAsync -private constructor( - private val orgSecretService: OrgSecretServiceAsync, - private val params: OrgSecretListParams, - private val response: Response, -) { +class OrgSecretListPageAsync private constructor(private val orgSecretService: OrgSecretServiceAsync, private val params: OrgSecretListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretListPageAsync && - this.orgSecretService == other.orgSecretService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is OrgSecretListPageAsync && + this.orgSecretService == other.orgSecretService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - orgSecretService, - params, - response, - ) + return Objects.hash( + orgSecretService, + params, + response, + ) } - override fun toString() = - "OrgSecretListPageAsync{orgSecretService=$orgSecretService, params=$params, response=$response}" + override fun toString() = "OrgSecretListPageAsync{orgSecretService=$orgSecretService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): OrgSecretListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - OrgSecretListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - OrgSecretListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + OrgSecretListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + OrgSecretListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): OrgSecretListPageAsync? { - return getNextPageParams()?.let { orgSecretService.list(it) } + return getNextPageParams()?.let { + orgSecretService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - orgSecretService: OrgSecretServiceAsync, - params: OrgSecretListParams, - response: Response - ) = - OrgSecretListPageAsync( - orgSecretService, - params, - response, - ) + fun of(orgSecretService: OrgSecretServiceAsync, params: OrgSecretListParams, response: Response) = OrgSecretListPageAsync( + orgSecretService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -106,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "OrgSecretListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "OrgSecretListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -159,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: OrgSecretListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: OrgSecretListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListParams.kt index ed8ff259..5ca776a2 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretListParams.kt @@ -2,34 +2,51 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class OrgSecretListParams constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val orgSecretName: String?, + private val orgSecretType: OrgSecretType?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class OrgSecretListParams -constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val orgSecretName: String?, - private val orgSecretType: OrgSecretType?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun endingBefore(): String? = endingBefore @@ -47,16 +64,30 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.orgSecretName?.let { params.put("org_secret_name", listOf(it.toString())) } - this.orgSecretType?.let { params.put("org_secret_type", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.orgSecretName?.let { + params.put("org_secret_name", listOf(it.toString())) + } + this.orgSecretType?.let { + params.put("org_secret_type", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -66,38 +97,37 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.orgSecretName == other.orgSecretName && - this.orgSecretType == other.orgSecretType && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is OrgSecretListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.orgSecretName == other.orgSecretName && + this.orgSecretType == other.orgSecretType && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - orgSecretName, - orgSecretType, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + orgSecretName, + orgSecretType, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "OrgSecretListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, orgSecretName=$orgSecretName, orgSecretType=$orgSecretType, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "OrgSecretListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, orgSecretName=$orgSecretName, orgSecretType=$orgSecretType, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -134,38 +164,52 @@ 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Name of the org_secret to search for */ - fun orgSecretName(orgSecretName: String) = apply { this.orgSecretName = orgSecretName } + fun orgSecretName(orgSecretName: String) = apply { + this.orgSecretName = orgSecretName + } fun orgSecretType(orgSecretType: OrgSecretType) = apply { this.orgSecretType = orgSecretType @@ -182,11 +226,13 @@ 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -226,83 +272,78 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): OrgSecretListParams = - OrgSecretListParams( - endingBefore, - ids, - limit, - orgName, - orgSecretName, - orgSecretType, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): OrgSecretListParams = OrgSecretListParams( + endingBefore, + ids, + limit, + orgName, + orgSecretName, + orgSecretType, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -319,105 +360,93 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + 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") + } } } } @JsonDeserialize(using = OrgSecretType.Deserializer::class) @JsonSerialize(using = OrgSecretType.Serializer::class) - class OrgSecretType - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class OrgSecretType private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): OrgSecretType = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown OrgSecretType: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown OrgSecretType: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is OrgSecretType && - this.string == other.string && - this.strings == other.strings + return other is OrgSecretType && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "OrgSecretType{string=$string}" - strings != null -> "OrgSecretType{strings=$strings}" - _json != null -> "OrgSecretType{_unknown=$_json}" - else -> throw IllegalStateException("Invalid OrgSecretType") - } + return when { + string != null -> "OrgSecretType{string=$string}" + strings != null -> "OrgSecretType{strings=$strings}" + _json != null -> "OrgSecretType{_unknown=$_json}" + else -> throw IllegalStateException("Invalid OrgSecretType") + } } companion object { @@ -434,38 +463,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown OrgSecretType: $json") + throw BraintrustInvalidDataException("Unknown OrgSecretType: $json") } } class Deserializer : BaseDeserializer(OrgSecretType::class) { override fun ObjectCodec.deserialize(node: JsonNode): OrgSecretType { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return OrgSecretType(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return OrgSecretType(strings = it, _json = json) - } - - return OrgSecretType(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return OrgSecretType(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return OrgSecretType(strings = it, _json = json) + } + + return OrgSecretType(_json = json) } } class Serializer : BaseSerializer(OrgSecretType::class) { - override fun serialize( - value: OrgSecretType, - 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 OrgSecretType") - } + override fun serialize(value: OrgSecretType, 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 OrgSecretType") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretReplaceParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretReplaceParams.kt index bd7b6143..ad9c992f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretReplaceParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretReplaceParams.kt @@ -2,27 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class OrgSecretReplaceParams constructor( + private val name: String, + private val metadata: Metadata?, + private val orgName: String?, + private val secret: String?, + private val type: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class OrgSecretReplaceParams -constructor( - private val name: String, - private val metadata: Metadata?, - private val orgName: String?, - private val secret: String?, - private val type: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -36,14 +59,14 @@ constructor( fun type(): String? = type internal fun getBody(): OrgSecretReplaceBody { - return OrgSecretReplaceBody( - name, - metadata, - orgName, - secret, - type, - additionalBodyProperties, - ) + return OrgSecretReplaceBody( + name, + metadata, + orgName, + secret, + type, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -52,37 +75,42 @@ constructor( @JsonDeserialize(builder = OrgSecretReplaceBody.Builder::class) @NoAutoDetect - class OrgSecretReplaceBody - internal constructor( - private val name: String?, - private val metadata: Metadata?, - private val orgName: String?, - private val secret: String?, - private val type: String?, - private val additionalProperties: Map, + class OrgSecretReplaceBody internal constructor( + private val name: String?, + private val metadata: Metadata?, + private val orgName: String?, + private val secret: String?, + private val type: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the org secret */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + @JsonProperty("metadata") + fun metadata(): 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 Org 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 Org Secret belongs in. */ - @JsonProperty("org_name") fun orgName(): String? = orgName + @JsonProperty("org_name") + fun orgName(): String? = 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") fun secret(): String? = secret + @JsonProperty("secret") + fun secret(): String? = secret - @JsonProperty("type") fun type(): String? = type + @JsonProperty("type") + fun type(): String? = type @JsonAnyGetter @ExcludeMissing @@ -91,36 +119,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretReplaceBody && - this.name == other.name && - this.metadata == other.metadata && - this.orgName == other.orgName && - this.secret == other.secret && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OrgSecretReplaceBody && + this.name == other.name && + this.metadata == other.metadata && + this.orgName == other.orgName && + this.secret == other.secret && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - metadata, - orgName, - secret, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + metadata, + orgName, + secret, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "OrgSecretReplaceBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "OrgSecretReplaceBody{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -146,26 +172,39 @@ constructor( } /** Name of the org secret */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = 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 Org 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 Org Secret belongs in. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = 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. */ - @JsonProperty("secret") fun secret(secret: String) = apply { this.secret = secret } + @JsonProperty("secret") + fun secret(secret: String) = apply { + this.secret = secret + } - @JsonProperty("type") fun type(type: String) = apply { this.type = type } + @JsonProperty("type") + fun type(type: String) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -181,15 +220,16 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): OrgSecretReplaceBody = - OrgSecretReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - metadata, - orgName, - secret, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): OrgSecretReplaceBody = OrgSecretReplaceBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + metadata, + orgName, + secret, + type, + additionalProperties.toUnmodifiable(), + ) } } @@ -200,36 +240,35 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretReplaceParams && - this.name == other.name && - this.metadata == other.metadata && - this.orgName == other.orgName && - this.secret == other.secret && - this.type == other.type && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrgSecretReplaceParams && + this.name == other.name && + this.metadata == other.metadata && + this.orgName == other.orgName && + this.secret == other.secret && + this.type == other.type && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - metadata, - orgName, - secret, - type, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + metadata, + orgName, + secret, + type, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "OrgSecretReplaceParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "OrgSecretReplaceParams{name=$name, metadata=$metadata, orgName=$orgName, secret=$secret, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -262,24 +301,34 @@ constructor( } /** Name of the org secret */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = 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 Org 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 Org Secret belongs in. */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = 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) = apply { this.secret = secret } + fun secret(secret: String) = apply { + this.secret = secret + } - fun type(type: String) = apply { this.type = type } + fun type(type: String) = apply { + this.type = type + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -319,7 +368,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -330,30 +381,27 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): OrgSecretReplaceParams = - OrgSecretReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - metadata, - orgName, - secret, - type, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): OrgSecretReplaceParams = OrgSecretReplaceParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + metadata, + orgName, + secret, + type, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var hashCode: Int = 0 @@ -364,18 +412,19 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretRetrieveParams.kt index c4d0ba3a..704ea249 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class OrgSecretRetrieveParams -constructor( - private val orgSecretId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class OrgSecretRetrieveParams constructor(private val orgSecretId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun orgSecretId(): String = orgSecretId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> orgSecretId - else -> "" - } + return when (index) { + 0 -> orgSecretId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretRetrieveParams && - this.orgSecretId == other.orgSecretId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is OrgSecretRetrieveParams && + this.orgSecretId == other.orgSecretId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - orgSecretId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + orgSecretId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "OrgSecretRetrieveParams{orgSecretId=$orgSecretId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "OrgSecretRetrieveParams{orgSecretId=$orgSecretId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** OrgSecret id */ - fun orgSecretId(orgSecretId: String) = apply { this.orgSecretId = orgSecretId } + fun orgSecretId(orgSecretId: String) = apply { + this.orgSecretId = orgSecretId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): OrgSecretRetrieveParams = - OrgSecretRetrieveParams( - checkNotNull(orgSecretId) { "`orgSecretId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): OrgSecretRetrieveParams = OrgSecretRetrieveParams( + checkNotNull(orgSecretId) { + "`orgSecretId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretUpdateParams.kt index 5e108663..1c9ef4db 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrgSecretUpdateParams.kt @@ -2,27 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class OrgSecretUpdateParams constructor( + private val orgSecretId: String, + private val metadata: Metadata?, + private val name: String?, + private val secret: String?, + private val type: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class OrgSecretUpdateParams -constructor( - private val orgSecretId: String, - private val metadata: Metadata?, - private val name: String?, - private val secret: String?, - private val type: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun orgSecretId(): String = orgSecretId @@ -36,13 +59,13 @@ constructor( fun type(): String? = type internal fun getBody(): OrgSecretUpdateBody { - return OrgSecretUpdateBody( - metadata, - name, - secret, - type, - additionalBodyProperties, - ) + return OrgSecretUpdateBody( + metadata, + name, + secret, + type, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -50,33 +73,37 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> orgSecretId - else -> "" - } + return when (index) { + 0 -> orgSecretId + else -> "" + } } @JsonDeserialize(builder = OrgSecretUpdateBody.Builder::class) @NoAutoDetect - class OrgSecretUpdateBody - internal constructor( - private val metadata: Metadata?, - private val name: String?, - private val secret: String?, - private val type: String?, - private val additionalProperties: Map, + class OrgSecretUpdateBody internal constructor( + private val metadata: Metadata?, + private val name: String?, + private val secret: String?, + private val type: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 - @JsonProperty("metadata") fun metadata(): Metadata? = metadata + @JsonProperty("metadata") + fun metadata(): Metadata? = metadata /** Name of the org secret */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name - @JsonProperty("secret") fun secret(): String? = secret + @JsonProperty("secret") + fun secret(): String? = secret - @JsonProperty("type") fun type(): String? = type + @JsonProperty("type") + fun type(): String? = type @JsonAnyGetter @ExcludeMissing @@ -85,34 +112,32 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretUpdateBody && - this.metadata == other.metadata && - this.name == other.name && - this.secret == other.secret && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OrgSecretUpdateBody && + this.metadata == other.metadata && + this.name == other.name && + this.secret == other.secret && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - metadata, - name, - secret, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + metadata, + name, + secret, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "OrgSecretUpdateBody{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "OrgSecretUpdateBody{metadata=$metadata, name=$name, secret=$secret, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -136,14 +161,25 @@ constructor( } @JsonProperty("metadata") - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = apply { + this.metadata = metadata + } /** Name of the org secret */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } - @JsonProperty("secret") fun secret(secret: String) = apply { this.secret = secret } + @JsonProperty("secret") + fun secret(secret: String) = apply { + this.secret = secret + } - @JsonProperty("type") fun type(type: String) = apply { this.type = type } + @JsonProperty("type") + fun type(type: String) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -159,14 +195,13 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): OrgSecretUpdateBody = - OrgSecretUpdateBody( - metadata, - name, - secret, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): OrgSecretUpdateBody = OrgSecretUpdateBody( + metadata, + name, + secret, + type, + additionalProperties.toUnmodifiable(), + ) } } @@ -177,36 +212,35 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrgSecretUpdateParams && - this.orgSecretId == other.orgSecretId && - this.metadata == other.metadata && - this.name == other.name && - this.secret == other.secret && - this.type == other.type && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrgSecretUpdateParams && + this.orgSecretId == other.orgSecretId && + this.metadata == other.metadata && + this.name == other.name && + this.secret == other.secret && + this.type == other.type && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - orgSecretId, - metadata, - name, - secret, - type, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + orgSecretId, + metadata, + name, + secret, + type, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "OrgSecretUpdateParams{orgSecretId=$orgSecretId, metadata=$metadata, name=$name, secret=$secret, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "OrgSecretUpdateParams{orgSecretId=$orgSecretId, metadata=$metadata, name=$name, secret=$secret, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -239,16 +273,26 @@ constructor( } /** OrgSecret id */ - fun orgSecretId(orgSecretId: String) = apply { this.orgSecretId = orgSecretId } + fun orgSecretId(orgSecretId: String) = apply { + this.orgSecretId = orgSecretId + } - fun metadata(metadata: Metadata) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata) = apply { + this.metadata = metadata + } /** Name of the org secret */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } - fun secret(secret: String) = apply { this.secret = secret } + fun secret(secret: String) = apply { + this.secret = secret + } - fun type(type: String) = apply { this.type = type } + fun type(type: String) = apply { + this.type = type + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -288,7 +332,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -299,30 +345,27 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): OrgSecretUpdateParams = - OrgSecretUpdateParams( - checkNotNull(orgSecretId) { "`orgSecretId` is required but was not set" }, - metadata, - name, - secret, - type, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): OrgSecretUpdateParams = OrgSecretUpdateParams( + checkNotNull(orgSecretId) { + "`orgSecretId` is required but was not set" + }, + metadata, + name, + secret, + type, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var hashCode: Int = 0 @@ -333,18 +376,19 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt index 4badd1ed..3763ccc6 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Organization.kt @@ -2,31 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Organization.Builder::class) @NoAutoDetect -class Organization -private constructor( - private val id: JsonField, - private val name: JsonField, - private val apiUrl: JsonField, - private val isUniversalApi: JsonField, - private val proxyUrl: JsonField, - private val realtimeUrl: JsonField, - private val created: JsonField, - private val additionalProperties: Map, +class Organization private constructor( + private val id: JsonField, + private val name: JsonField, + private val apiUrl: JsonField, + private val isUniversalApi: JsonField, + private val proxyUrl: JsonField, + private val realtimeUrl: JsonField, + private val created: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -51,21 +69,35 @@ private constructor( fun created(): OffsetDateTime? = created.getNullable("created") /** Unique identifier for the organization */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** Name of the organization */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name - @JsonProperty("api_url") @ExcludeMissing fun _apiUrl() = apiUrl + @JsonProperty("api_url") + @ExcludeMissing + fun _apiUrl() = apiUrl - @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi() = isUniversalApi + @JsonProperty("is_universal_api") + @ExcludeMissing + fun _isUniversalApi() = isUniversalApi - @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl() = proxyUrl + @JsonProperty("proxy_url") + @ExcludeMissing + fun _proxyUrl() = proxyUrl - @JsonProperty("realtime_url") @ExcludeMissing fun _realtimeUrl() = realtimeUrl + @JsonProperty("realtime_url") + @ExcludeMissing + fun _realtimeUrl() = realtimeUrl /** Date of organization creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created @JsonAnyGetter @ExcludeMissing @@ -73,54 +105,52 @@ private constructor( fun validate(): Organization = apply { if (!validated) { - id() - name() - apiUrl() - isUniversalApi() - proxyUrl() - realtimeUrl() - created() - validated = true + id() + name() + apiUrl() + isUniversalApi() + proxyUrl() + realtimeUrl() + created() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Organization && - this.id == other.id && - this.name == other.name && - this.apiUrl == other.apiUrl && - this.isUniversalApi == other.isUniversalApi && - this.proxyUrl == other.proxyUrl && - this.realtimeUrl == other.realtimeUrl && - this.created == other.created && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Organization && + this.id == other.id && + this.name == other.name && + this.apiUrl == other.apiUrl && + this.isUniversalApi == other.isUniversalApi && + this.proxyUrl == other.proxyUrl && + this.realtimeUrl == other.realtimeUrl && + this.created == other.created && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - name, - apiUrl, - isUniversalApi, - proxyUrl, - realtimeUrl, - created, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + name, + apiUrl, + isUniversalApi, + proxyUrl, + realtimeUrl, + created, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Organization{id=$id, name=$name, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, created=$created, additionalProperties=$additionalProperties}" + override fun toString() = "Organization{id=$id, name=$name, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, created=$created, additionalProperties=$additionalProperties}" companion object { @@ -153,7 +183,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the organization */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** Name of the organization */ fun name(name: String) = name(JsonField.of(name)) @@ -161,13 +195,17 @@ private constructor( /** Name of the organization */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } fun apiUrl(apiUrl: String) = apiUrl(JsonField.of(apiUrl)) @JsonProperty("api_url") @ExcludeMissing - fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } + fun apiUrl(apiUrl: JsonField) = apply { + this.apiUrl = apiUrl + } fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(JsonField.of(isUniversalApi)) @@ -181,13 +219,17 @@ private constructor( @JsonProperty("proxy_url") @ExcludeMissing - fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } + fun proxyUrl(proxyUrl: JsonField) = apply { + this.proxyUrl = proxyUrl + } fun realtimeUrl(realtimeUrl: String) = realtimeUrl(JsonField.of(realtimeUrl)) @JsonProperty("realtime_url") @ExcludeMissing - fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } + fun realtimeUrl(realtimeUrl: JsonField) = apply { + this.realtimeUrl = realtimeUrl + } /** Date of organization creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -195,7 +237,9 @@ private constructor( /** Date of organization creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -211,16 +255,15 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Organization = - Organization( - id, - name, - apiUrl, - isUniversalApi, - proxyUrl, - realtimeUrl, - created, - additionalProperties.toUnmodifiable(), - ) + fun build(): Organization = Organization( + id, + name, + apiUrl, + isUniversalApi, + proxyUrl, + realtimeUrl, + created, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt index 3b40e3f9..abade175 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class OrganizationDeleteParams -constructor( - private val organizationId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class OrganizationDeleteParams constructor( + private val organizationId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun organizationId(): String = organizationId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationDeleteParams && - this.organizationId == other.organizationId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrganizationDeleteParams && + this.organizationId == other.organizationId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - organizationId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + organizationId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "OrganizationDeleteParams{organizationId=$organizationId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "OrganizationDeleteParams{organizationId=$organizationId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** Organization id */ - fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun organizationId(organizationId: String) = apply { + this.organizationId = organizationId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): OrganizationDeleteParams = - OrganizationDeleteParams( - checkNotNull(organizationId) { "`organizationId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): OrganizationDeleteParams = OrganizationDeleteParams( + checkNotNull(organizationId) { + "`organizationId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt index b7ae0a05..1a213755 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPage.kt @@ -2,107 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Organization import com.braintrustdata.api.services.blocking.OrganizationService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class OrganizationListPage -private constructor( - private val organizationService: OrganizationService, - private val params: OrganizationListParams, - private val response: Response, -) { +class OrganizationListPage private constructor(private val organizationService: OrganizationService, private val params: OrganizationListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationListPage && - this.organizationService == other.organizationService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is OrganizationListPage && + this.organizationService == other.organizationService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - organizationService, - params, - response, - ) + return Objects.hash( + organizationService, + params, + response, + ) } - override fun toString() = - "OrganizationListPage{organizationService=$organizationService, params=$params, response=$response}" + override fun toString() = "OrganizationListPage{organizationService=$organizationService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): OrganizationListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - OrganizationListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - } else { - OrganizationListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + OrganizationListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + OrganizationListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): OrganizationListPage? { - return getNextPageParams()?.let { organizationService.list(it) } + return getNextPageParams()?.let { + organizationService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - organizationService: OrganizationService, - params: OrganizationListParams, - response: Response - ) = - OrganizationListPage( - organizationService, - params, - response, - ) + fun of(organizationService: OrganizationService, params: OrganizationListParams, response: Response) = OrganizationListPage( + organizationService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -110,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "OrganizationListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "OrganizationListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -163,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: OrganizationListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: OrganizationListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt index 498124fc..aace9fe3 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListPageAsync.kt @@ -2,109 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.OrganizationServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Organization +import com.braintrustdata.api.services.async.OrganizationServiceAsync -class OrganizationListPageAsync -private constructor( - private val organizationService: OrganizationServiceAsync, - private val params: OrganizationListParams, - private val response: Response, -) { +class OrganizationListPageAsync private constructor(private val organizationService: OrganizationServiceAsync, private val params: OrganizationListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationListPageAsync && - this.organizationService == other.organizationService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is OrganizationListPageAsync && + this.organizationService == other.organizationService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - organizationService, - params, - response, - ) + return Objects.hash( + organizationService, + params, + response, + ) } - override fun toString() = - "OrganizationListPageAsync{organizationService=$organizationService, params=$params, response=$response}" + override fun toString() = "OrganizationListPageAsync{organizationService=$organizationService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): OrganizationListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - OrganizationListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - } else { - OrganizationListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + OrganizationListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + OrganizationListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): OrganizationListPageAsync? { - return getNextPageParams()?.let { organizationService.list(it) } + return getNextPageParams()?.let { + organizationService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - organizationService: OrganizationServiceAsync, - params: OrganizationListParams, - response: Response - ) = - OrganizationListPageAsync( - organizationService, - params, - response, - ) + fun of(organizationService: OrganizationServiceAsync, params: OrganizationListParams, response: Response) = OrganizationListPageAsync( + organizationService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -112,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "OrganizationListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "OrganizationListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -165,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: OrganizationListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: OrganizationListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt index b570466f..3fec0b64 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationListParams.kt @@ -2,32 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class OrganizationListParams constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class OrganizationListParams -constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun endingBefore(): String? = endingBefore @@ -41,14 +58,24 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -58,34 +85,33 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is OrganizationListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "OrganizationListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -118,44 +144,58 @@ 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -195,81 +235,76 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): OrganizationListParams = - OrganizationListParams( - endingBefore, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): OrganizationListParams = OrganizationListParams( + endingBefore, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -286,38 +321,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt index 91a966ee..c3c8592d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParams.kt @@ -2,26 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class OrganizationMemberUpdateParams constructor( + private val inviteUsers: InviteUsers?, + private val orgId: String?, + private val orgName: String?, + private val removeUsers: RemoveUsers?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class OrganizationMemberUpdateParams -constructor( - private val inviteUsers: InviteUsers?, - private val orgId: String?, - private val orgName: String?, - private val removeUsers: RemoveUsers?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun inviteUsers(): InviteUsers? = inviteUsers @@ -33,13 +56,13 @@ constructor( fun removeUsers(): RemoveUsers? = removeUsers internal fun getBody(): OrganizationMemberUpdateBody { - return OrganizationMemberUpdateBody( - inviteUsers, - orgId, - orgName, - removeUsers, - additionalBodyProperties, - ) + return OrganizationMemberUpdateBody( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -48,36 +71,42 @@ constructor( @JsonDeserialize(builder = OrganizationMemberUpdateBody.Builder::class) @NoAutoDetect - class OrganizationMemberUpdateBody - internal constructor( - private val inviteUsers: InviteUsers?, - private val orgId: String?, - private val orgName: String?, - private val removeUsers: RemoveUsers?, - private val additionalProperties: Map, + class OrganizationMemberUpdateBody internal constructor( + private val inviteUsers: InviteUsers?, + private val orgId: String?, + private val orgName: String?, + private val removeUsers: RemoveUsers?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Users to invite to the organization */ - @JsonProperty("invite_users") fun inviteUsers(): InviteUsers? = inviteUsers + @JsonProperty("invite_users") + fun inviteUsers(): 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. */ - @JsonProperty("org_id") fun orgId(): String? = orgId + @JsonProperty("org_id") + fun orgId(): String? = 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") fun orgName(): String? = orgName + @JsonProperty("org_name") + fun orgName(): String? = orgName /** Users to remove from the organization */ - @JsonProperty("remove_users") fun removeUsers(): RemoveUsers? = removeUsers + @JsonProperty("remove_users") + fun removeUsers(): RemoveUsers? = removeUsers @JsonAnyGetter @ExcludeMissing @@ -86,34 +115,32 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationMemberUpdateBody && - this.inviteUsers == other.inviteUsers && - this.orgId == other.orgId && - this.orgName == other.orgName && - this.removeUsers == other.removeUsers && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OrganizationMemberUpdateBody && + this.inviteUsers == other.inviteUsers && + this.orgId == other.orgId && + this.orgName == other.orgName && + this.removeUsers == other.removeUsers && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - inviteUsers, - orgId, - orgName, - removeUsers, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "OrganizationMemberUpdateBody{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" + override fun toString() = "OrganizationMemberUpdateBody{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalProperties=$additionalProperties}" companion object { @@ -138,28 +165,37 @@ constructor( /** Users to invite to the organization */ @JsonProperty("invite_users") - fun inviteUsers(inviteUsers: InviteUsers) = apply { this.inviteUsers = inviteUsers } + fun inviteUsers(inviteUsers: InviteUsers) = 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. */ - @JsonProperty("org_id") fun orgId(orgId: String) = apply { this.orgId = orgId } + @JsonProperty("org_id") + fun orgId(orgId: String) = 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. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Users to remove from the organization */ @JsonProperty("remove_users") - fun removeUsers(removeUsers: RemoveUsers) = apply { this.removeUsers = removeUsers } + fun removeUsers(removeUsers: RemoveUsers) = apply { + this.removeUsers = removeUsers + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -175,14 +211,13 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): OrganizationMemberUpdateBody = - OrganizationMemberUpdateBody( - inviteUsers, - orgId, - orgName, - removeUsers, - additionalProperties.toUnmodifiable(), - ) + fun build(): OrganizationMemberUpdateBody = OrganizationMemberUpdateBody( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalProperties.toUnmodifiable(), + ) } } @@ -193,34 +228,33 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationMemberUpdateParams && - this.inviteUsers == other.inviteUsers && - this.orgId == other.orgId && - this.orgName == other.orgName && - this.removeUsers == other.removeUsers && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrganizationMemberUpdateParams && + this.inviteUsers == other.inviteUsers && + this.orgId == other.orgId && + this.orgName == other.orgName && + this.removeUsers == other.removeUsers && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - inviteUsers, - orgId, - orgName, - removeUsers, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "OrganizationMemberUpdateParams{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "OrganizationMemberUpdateParams{inviteUsers=$inviteUsers, orgId=$orgId, orgName=$orgName, removeUsers=$removeUsers, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -251,24 +285,34 @@ constructor( } /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: InviteUsers) = apply { this.inviteUsers = inviteUsers } + fun inviteUsers(inviteUsers: InviteUsers) = 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) = apply { this.orgId = orgId } + fun orgId(orgId: String) = 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) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Users to remove from the organization */ - fun removeUsers(removeUsers: RemoveUsers) = apply { this.removeUsers = removeUsers } + fun removeUsers(removeUsers: RemoveUsers) = apply { + this.removeUsers = removeUsers + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -308,7 +352,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -319,60 +365,65 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): OrganizationMemberUpdateParams = - OrganizationMemberUpdateParams( - inviteUsers, - orgId, - orgName, - removeUsers, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): OrganizationMemberUpdateParams = OrganizationMemberUpdateParams( + inviteUsers, + orgId, + orgName, + removeUsers, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** Users to invite to the organization */ @JsonDeserialize(builder = InviteUsers.Builder::class) @NoAutoDetect - class InviteUsers - private constructor( - private val ids: List?, - private val emails: List?, - private val sendInviteEmails: Boolean?, - private val groupIds: List?, - private val groupNames: List?, - private val groupId: String?, - private val groupName: String?, - private val additionalProperties: Map, + class InviteUsers private constructor( + private val ids: List?, + private val emails: List?, + private val sendInviteEmails: Boolean?, + private val groupIds: List?, + private val groupNames: List?, + private val groupId: String?, + private val groupName: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Ids of existing users to invite */ - @JsonProperty("ids") fun ids(): List? = ids + @JsonProperty("ids") + fun ids(): List? = ids /** Emails of users to invite */ - @JsonProperty("emails") fun emails(): List? = emails + @JsonProperty("emails") + fun emails(): List? = emails /** If true, send invite emails to the users who wore actually added */ - @JsonProperty("send_invite_emails") fun sendInviteEmails(): Boolean? = sendInviteEmails + @JsonProperty("send_invite_emails") + fun sendInviteEmails(): Boolean? = sendInviteEmails /** Optional list of group ids to add newly-invited users to. */ - @JsonProperty("group_ids") fun groupIds(): List? = groupIds + @JsonProperty("group_ids") + fun groupIds(): List? = groupIds /** Optional list of group names to add newly-invited users to. */ - @JsonProperty("group_names") fun groupNames(): List? = groupNames + @JsonProperty("group_names") + fun groupNames(): List? = groupNames /** Singular form of group_ids */ - @JsonProperty("group_id") fun groupId(): String? = groupId + @JsonProperty("group_id") + fun groupId(): String? = groupId /** Singular form of group_names */ - @JsonProperty("group_name") fun groupName(): String? = groupName + @JsonProperty("group_name") + fun groupName(): String? = groupName @JsonAnyGetter @ExcludeMissing @@ -381,40 +432,38 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InviteUsers && - this.ids == other.ids && - this.emails == other.emails && - this.sendInviteEmails == other.sendInviteEmails && - this.groupIds == other.groupIds && - this.groupNames == other.groupNames && - this.groupId == other.groupId && - this.groupName == other.groupName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is InviteUsers && + this.ids == other.ids && + this.emails == other.emails && + this.sendInviteEmails == other.sendInviteEmails && + this.groupIds == other.groupIds && + this.groupNames == other.groupNames && + this.groupId == other.groupId && + this.groupName == other.groupName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - ids, - emails, - sendInviteEmails, - groupIds, - groupNames, - groupId, - groupName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + ids, + emails, + sendInviteEmails, + groupIds, + groupNames, + groupId, + groupName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "InviteUsers{ids=$ids, emails=$emails, sendInviteEmails=$sendInviteEmails, groupIds=$groupIds, groupNames=$groupNames, groupId=$groupId, groupName=$groupName, additionalProperties=$additionalProperties}" + override fun toString() = "InviteUsers{ids=$ids, emails=$emails, sendInviteEmails=$sendInviteEmails, groupIds=$groupIds, groupNames=$groupNames, groupId=$groupId, groupName=$groupName, additionalProperties=$additionalProperties}" companion object { @@ -444,11 +493,16 @@ constructor( } /** Ids of existing users to invite */ - @JsonProperty("ids") fun ids(ids: List) = apply { this.ids = ids } + @JsonProperty("ids") + fun ids(ids: List) = apply { + this.ids = ids + } /** Emails of users to invite */ @JsonProperty("emails") - fun emails(emails: List) = apply { this.emails = emails } + fun emails(emails: List) = apply { + this.emails = emails + } /** If true, send invite emails to the users who wore actually added */ @JsonProperty("send_invite_emails") @@ -458,19 +512,27 @@ constructor( /** Optional list of group ids to add newly-invited users to. */ @JsonProperty("group_ids") - fun groupIds(groupIds: List) = apply { this.groupIds = groupIds } + fun groupIds(groupIds: List) = apply { + this.groupIds = groupIds + } /** Optional list of group names to add newly-invited users to. */ @JsonProperty("group_names") - fun groupNames(groupNames: List) = apply { this.groupNames = groupNames } + fun groupNames(groupNames: List) = apply { + this.groupNames = groupNames + } /** Singular form of group_ids */ @JsonProperty("group_id") - fun groupId(groupId: String) = apply { this.groupId = groupId } + fun groupId(groupId: String) = apply { + this.groupId = groupId + } /** Singular form of group_names */ @JsonProperty("group_name") - fun groupName(groupName: String) = apply { this.groupName = groupName } + fun groupName(groupName: String) = apply { + this.groupName = groupName + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -486,37 +548,33 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): InviteUsers = - InviteUsers( - ids?.toUnmodifiable(), - emails?.toUnmodifiable(), - sendInviteEmails, - groupIds?.toUnmodifiable(), - groupNames?.toUnmodifiable(), - groupId, - groupName, - additionalProperties.toUnmodifiable(), - ) + fun build(): InviteUsers = InviteUsers( + ids?.toUnmodifiable(), + emails?.toUnmodifiable(), + sendInviteEmails, + groupIds?.toUnmodifiable(), + groupNames?.toUnmodifiable(), + groupId, + groupName, + additionalProperties.toUnmodifiable(), + ) } } /** Users to remove from the organization */ @JsonDeserialize(builder = RemoveUsers.Builder::class) @NoAutoDetect - class RemoveUsers - private constructor( - private val ids: List?, - private val emails: List?, - private val additionalProperties: Map, - ) { + class RemoveUsers private constructor(private val ids: List?, private val emails: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Ids of users to remove */ - @JsonProperty("ids") fun ids(): List? = ids + @JsonProperty("ids") + fun ids(): List? = ids /** Emails of users to remove */ - @JsonProperty("emails") fun emails(): List? = emails + @JsonProperty("emails") + fun emails(): List? = emails @JsonAnyGetter @ExcludeMissing @@ -525,30 +583,28 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveUsers && - this.ids == other.ids && - this.emails == other.emails && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RemoveUsers && + this.ids == other.ids && + this.emails == other.emails && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - ids, - emails, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + ids, + emails, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RemoveUsers{ids=$ids, emails=$emails, additionalProperties=$additionalProperties}" + override fun toString() = "RemoveUsers{ids=$ids, emails=$emails, additionalProperties=$additionalProperties}" companion object { @@ -568,11 +624,16 @@ constructor( } /** Ids of users to remove */ - @JsonProperty("ids") fun ids(ids: List) = apply { this.ids = ids } + @JsonProperty("ids") + fun ids(ids: List) = apply { + this.ids = ids + } /** Emails of users to remove */ @JsonProperty("emails") - fun emails(emails: List) = apply { this.emails = emails } + fun emails(emails: List) = apply { + this.emails = emails + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -588,12 +649,11 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RemoveUsers = - RemoveUsers( - ids?.toUnmodifiable(), - emails?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): RemoveUsers = RemoveUsers( + ids?.toUnmodifiable(), + emails?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponse.kt index 6643c33f..f50c791d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponse.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponse.kt @@ -2,29 +2,40 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = OrganizationMemberUpdateResponse.Builder::class) @NoAutoDetect -class OrganizationMemberUpdateResponse -private constructor( - private val status: JsonField, - private val sendEmailError: JsonField, - private val additionalProperties: Map, -) { +class OrganizationMemberUpdateResponse private constructor(private val status: JsonField, private val sendEmailError: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -33,18 +44,22 @@ 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(): String? = sendEmailError.getNullable("send_email_error") - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") + @ExcludeMissing + fun _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 */ - @JsonProperty("send_email_error") @ExcludeMissing fun _sendEmailError() = sendEmailError + @JsonProperty("send_email_error") + @ExcludeMissing + fun _sendEmailError() = sendEmailError @JsonAnyGetter @ExcludeMissing @@ -52,39 +67,37 @@ private constructor( fun validate(): OrganizationMemberUpdateResponse = apply { if (!validated) { - status() - sendEmailError() - validated = true + status() + sendEmailError() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationMemberUpdateResponse && - this.status == other.status && - this.sendEmailError == other.sendEmailError && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OrganizationMemberUpdateResponse && + this.status == other.status && + this.sendEmailError == other.sendEmailError && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - status, - sendEmailError, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + status, + sendEmailError, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "OrganizationMemberUpdateResponse{status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" + override fun toString() = "OrganizationMemberUpdateResponse{status=$status, sendEmailError=$sendEmailError, additionalProperties=$additionalProperties}" companion object { @@ -97,28 +110,29 @@ private constructor( private var sendEmailError: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(organizationMemberUpdateResponse: OrganizationMemberUpdateResponse) = - apply { - this.status = organizationMemberUpdateResponse.status - this.sendEmailError = organizationMemberUpdateResponse.sendEmailError - additionalProperties(organizationMemberUpdateResponse.additionalProperties) - } + internal fun from(organizationMemberUpdateResponse: OrganizationMemberUpdateResponse) = apply { + this.status = organizationMemberUpdateResponse.status + this.sendEmailError = organizationMemberUpdateResponse.sendEmailError + additionalProperties(organizationMemberUpdateResponse.additionalProperties) + } fun status(status: Status) = status(JsonField.of(status)) @JsonProperty("status") @ExcludeMissing - 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.of(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 */ @JsonProperty("send_email_error") @ExcludeMissing @@ -140,28 +154,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): OrganizationMemberUpdateResponse = - OrganizationMemberUpdateResponse( - status, - sendEmailError, - additionalProperties.toUnmodifiable(), - ) + fun build(): OrganizationMemberUpdateResponse = OrganizationMemberUpdateResponse( + status, + sendEmailError, + additionalProperties.toUnmodifiable(), + ) } - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Status @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Status && this.value == other.value + return other is Status && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -184,17 +195,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SUCCESS -> Value.SUCCESS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SUCCESS -> Known.SUCCESS - else -> throw BraintrustInvalidDataException("Unknown Status: $value") - } + fun value(): Value = when (this) { + SUCCESS -> Value.SUCCESS + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + SUCCESS -> Known.SUCCESS + else -> throw BraintrustInvalidDataException("Unknown Status: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt index a49d188c..49fb46e4 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class OrganizationRetrieveParams -constructor( - private val organizationId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class OrganizationRetrieveParams constructor(private val organizationId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun organizationId(): String = organizationId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationRetrieveParams && - this.organizationId == other.organizationId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is OrganizationRetrieveParams && + this.organizationId == other.organizationId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - organizationId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + organizationId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "OrganizationRetrieveParams{organizationId=$organizationId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "OrganizationRetrieveParams{organizationId=$organizationId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** Organization id */ - fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun organizationId(organizationId: String) = apply { + this.organizationId = organizationId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): OrganizationRetrieveParams = - OrganizationRetrieveParams( - checkNotNull(organizationId) { "`organizationId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): OrganizationRetrieveParams = OrganizationRetrieveParams( + checkNotNull(organizationId) { + "`organizationId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt index 2debad5b..e5510116 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/OrganizationUpdateParams.kt @@ -2,28 +2,51 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class OrganizationUpdateParams constructor( + private val organizationId: String, + private val apiUrl: String?, + private val isUniversalApi: Boolean?, + private val name: String?, + private val proxyUrl: String?, + private val realtimeUrl: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class OrganizationUpdateParams -constructor( - private val organizationId: String, - private val apiUrl: String?, - private val isUniversalApi: Boolean?, - private val name: String?, - private val proxyUrl: String?, - private val realtimeUrl: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun organizationId(): String = organizationId @@ -39,14 +62,14 @@ constructor( fun realtimeUrl(): String? = realtimeUrl internal fun getBody(): OrganizationUpdateBody { - return OrganizationUpdateBody( - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalBodyProperties, - ) + return OrganizationUpdateBody( + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -54,36 +77,41 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> organizationId - else -> "" - } + return when (index) { + 0 -> organizationId + else -> "" + } } @JsonDeserialize(builder = OrganizationUpdateBody.Builder::class) @NoAutoDetect - class OrganizationUpdateBody - internal constructor( - private val apiUrl: String?, - private val isUniversalApi: Boolean?, - private val name: String?, - private val proxyUrl: String?, - private val realtimeUrl: String?, - private val additionalProperties: Map, + class OrganizationUpdateBody internal constructor( + private val apiUrl: String?, + private val isUniversalApi: Boolean?, + private val name: String?, + private val proxyUrl: String?, + private val realtimeUrl: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 - @JsonProperty("api_url") fun apiUrl(): String? = apiUrl + @JsonProperty("api_url") + fun apiUrl(): String? = apiUrl - @JsonProperty("is_universal_api") fun isUniversalApi(): Boolean? = isUniversalApi + @JsonProperty("is_universal_api") + fun isUniversalApi(): Boolean? = isUniversalApi /** Name of the organization */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name - @JsonProperty("proxy_url") fun proxyUrl(): String? = proxyUrl + @JsonProperty("proxy_url") + fun proxyUrl(): String? = proxyUrl - @JsonProperty("realtime_url") fun realtimeUrl(): String? = realtimeUrl + @JsonProperty("realtime_url") + fun realtimeUrl(): String? = realtimeUrl @JsonAnyGetter @ExcludeMissing @@ -92,36 +120,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationUpdateBody && - this.apiUrl == other.apiUrl && - this.isUniversalApi == other.isUniversalApi && - this.name == other.name && - this.proxyUrl == other.proxyUrl && - this.realtimeUrl == other.realtimeUrl && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OrganizationUpdateBody && + this.apiUrl == other.apiUrl && + this.isUniversalApi == other.isUniversalApi && + this.name == other.name && + this.proxyUrl == other.proxyUrl && + this.realtimeUrl == other.realtimeUrl && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "OrganizationUpdateBody{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" + override fun toString() = "OrganizationUpdateBody{apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" companion object { @@ -146,7 +172,10 @@ constructor( additionalProperties(organizationUpdateBody.additionalProperties) } - @JsonProperty("api_url") fun apiUrl(apiUrl: String) = apply { this.apiUrl = apiUrl } + @JsonProperty("api_url") + fun apiUrl(apiUrl: String) = apply { + this.apiUrl = apiUrl + } @JsonProperty("is_universal_api") fun isUniversalApi(isUniversalApi: Boolean) = apply { @@ -154,13 +183,20 @@ constructor( } /** Name of the organization */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } @JsonProperty("proxy_url") - fun proxyUrl(proxyUrl: String) = apply { this.proxyUrl = proxyUrl } + fun proxyUrl(proxyUrl: String) = apply { + this.proxyUrl = proxyUrl + } @JsonProperty("realtime_url") - fun realtimeUrl(realtimeUrl: String) = apply { this.realtimeUrl = realtimeUrl } + fun realtimeUrl(realtimeUrl: String) = apply { + this.realtimeUrl = realtimeUrl + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -176,15 +212,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): OrganizationUpdateBody = - OrganizationUpdateBody( - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalProperties.toUnmodifiable(), - ) + fun build(): OrganizationUpdateBody = OrganizationUpdateBody( + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalProperties.toUnmodifiable(), + ) } } @@ -195,38 +230,37 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OrganizationUpdateParams && - this.organizationId == other.organizationId && - this.apiUrl == other.apiUrl && - this.isUniversalApi == other.isUniversalApi && - this.name == other.name && - this.proxyUrl == other.proxyUrl && - this.realtimeUrl == other.realtimeUrl && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is OrganizationUpdateParams && + this.organizationId == other.organizationId && + this.apiUrl == other.apiUrl && + this.isUniversalApi == other.isUniversalApi && + this.name == other.name && + this.proxyUrl == other.proxyUrl && + this.realtimeUrl == other.realtimeUrl && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - organizationId, - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + organizationId, + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "OrganizationUpdateParams{organizationId=$organizationId, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "OrganizationUpdateParams{organizationId=$organizationId, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, name=$name, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -261,18 +295,30 @@ constructor( } /** Organization id */ - fun organizationId(organizationId: String) = apply { this.organizationId = organizationId } + fun organizationId(organizationId: String) = apply { + this.organizationId = organizationId + } - fun apiUrl(apiUrl: String) = apply { this.apiUrl = apiUrl } + fun apiUrl(apiUrl: String) = apply { + this.apiUrl = apiUrl + } - fun isUniversalApi(isUniversalApi: Boolean) = apply { this.isUniversalApi = isUniversalApi } + fun isUniversalApi(isUniversalApi: Boolean) = apply { + this.isUniversalApi = isUniversalApi + } /** Name of the organization */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } - fun proxyUrl(proxyUrl: String) = apply { this.proxyUrl = proxyUrl } + fun proxyUrl(proxyUrl: String) = apply { + this.proxyUrl = proxyUrl + } - fun realtimeUrl(realtimeUrl: String) = apply { this.realtimeUrl = realtimeUrl } + fun realtimeUrl(realtimeUrl: String) = apply { + this.realtimeUrl = realtimeUrl + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -312,7 +358,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -323,22 +371,22 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): OrganizationUpdateParams = - OrganizationUpdateParams( - checkNotNull(organizationId) { "`organizationId` is required but was not set" }, - apiUrl, - isUniversalApi, - name, - proxyUrl, - realtimeUrl, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): OrganizationUpdateParams = OrganizationUpdateParams( + checkNotNull(organizationId) { + "`organizationId` is required but was not set" + }, + apiUrl, + isUniversalApi, + name, + proxyUrl, + realtimeUrl, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchDataset.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchDataset.kt deleted file mode 100755 index 885b4552..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchDataset.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = PatchDataset.Builder::class) -@NoAutoDetect -class PatchDataset -private constructor( - private val name: JsonField, - private val description: JsonField, - private val metadata: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the dataset. Within a project, dataset names are unique */ - fun name(): String? = name.getNullable("name") - - /** Textual description of the dataset */ - fun description(): String? = description.getNullable("description") - - /** User-controlled metadata about the dataset */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the dataset */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchDataset = apply { - if (!validated) { - name() - description() - metadata()?.validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchDataset && - this.name == other.name && - this.description == other.description && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - metadata, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchDataset{name=$name, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchDataset: PatchDataset) = apply { - this.name = patchDataset.name - this.description = patchDataset.description - this.metadata = patchDataset.metadata - additionalProperties(patchDataset.additionalProperties) - } - - /** Name of the dataset. Within a project, dataset names are unique */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the dataset. Within a project, dataset names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the dataset */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the dataset */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** User-controlled metadata about the dataset */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** User-controlled metadata about the dataset */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchDataset = - PatchDataset( - name, - description, - metadata, - additionalProperties.toUnmodifiable(), - ) - } - - /** User-controlled metadata about the dataset */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchExperiment.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchExperiment.kt deleted file mode 100755 index d730e923..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchExperiment.kt +++ /dev/null @@ -1,364 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = PatchExperiment.Builder::class) -@NoAutoDetect -class PatchExperiment -private constructor( - private val name: JsonField, - private val description: JsonField, - private val repoInfo: JsonField, - private val baseExpId: JsonField, - private val datasetId: JsonField, - private val datasetVersion: JsonField, - private val public_: JsonField, - private val metadata: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the experiment. Within a project, experiment names are unique */ - fun name(): String? = name.getNullable("name") - - /** Textual description of the experiment */ - fun description(): String? = description.getNullable("description") - - /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(): RepoInfo? = repoInfo.getNullable("repo_info") - - /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(): String? = baseExpId.getNullable("base_exp_id") - - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - fun datasetId(): String? = datasetId.getNullable("dataset_id") - - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ - fun datasetVersion(): String? = datasetVersion.getNullable("dataset_version") - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization - */ - fun public_(): Boolean? = public_.getNullable("public") - - /** User-controlled metadata about the experiment */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the experiment */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") @ExcludeMissing fun _repoInfo() = repoInfo - - /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") @ExcludeMissing fun _baseExpId() = baseExpId - - /** Identifier of the linked dataset, or null if the experiment is not linked to a dataset */ - @JsonProperty("dataset_id") @ExcludeMissing fun _datasetId() = datasetId - - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ - @JsonProperty("dataset_version") @ExcludeMissing fun _datasetVersion() = datasetVersion - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody inside - * or outside the organization - */ - @JsonProperty("public") @ExcludeMissing fun _public_() = public_ - - /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchExperiment = apply { - if (!validated) { - name() - description() - repoInfo()?.validate() - baseExpId() - datasetId() - datasetVersion() - public_() - metadata()?.validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchExperiment && - this.name == other.name && - this.description == other.description && - this.repoInfo == other.repoInfo && - this.baseExpId == other.baseExpId && - this.datasetId == other.datasetId && - this.datasetVersion == other.datasetVersion && - this.public_ == other.public_ && - this.metadata == other.metadata && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - repoInfo, - baseExpId, - datasetId, - datasetVersion, - public_, - metadata, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchExperiment{name=$name, description=$description, repoInfo=$repoInfo, baseExpId=$baseExpId, datasetId=$datasetId, datasetVersion=$datasetVersion, public_=$public_, metadata=$metadata, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var repoInfo: JsonField = JsonMissing.of() - private var baseExpId: JsonField = JsonMissing.of() - private var datasetId: JsonField = JsonMissing.of() - private var datasetVersion: JsonField = JsonMissing.of() - private var public_: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchExperiment: PatchExperiment) = apply { - this.name = patchExperiment.name - this.description = patchExperiment.description - this.repoInfo = patchExperiment.repoInfo - this.baseExpId = patchExperiment.baseExpId - this.datasetId = patchExperiment.datasetId - this.datasetVersion = patchExperiment.datasetVersion - this.public_ = patchExperiment.public_ - this.metadata = patchExperiment.metadata - additionalProperties(patchExperiment.additionalProperties) - } - - /** Name of the experiment. Within a project, experiment names are unique */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the experiment. Within a project, experiment names are unique */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the experiment */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the experiment */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Metadata about the state of the repo when the experiment was created */ - fun repoInfo(repoInfo: RepoInfo) = repoInfo(JsonField.of(repoInfo)) - - /** Metadata about the state of the repo when the experiment was created */ - @JsonProperty("repo_info") - @ExcludeMissing - fun repoInfo(repoInfo: JsonField) = apply { this.repoInfo = repoInfo } - - /** Id of default base experiment to compare against when viewing this experiment */ - fun baseExpId(baseExpId: String) = baseExpId(JsonField.of(baseExpId)) - - /** Id of default base experiment to compare against when viewing this experiment */ - @JsonProperty("base_exp_id") - @ExcludeMissing - fun baseExpId(baseExpId: JsonField) = apply { this.baseExpId = baseExpId } - - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset - */ - fun datasetId(datasetId: String) = datasetId(JsonField.of(datasetId)) - - /** - * Identifier of the linked dataset, or null if the experiment is not linked to a dataset - */ - @JsonProperty("dataset_id") - @ExcludeMissing - fun datasetId(datasetId: JsonField) = apply { this.datasetId = datasetId } - - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ - fun datasetVersion(datasetVersion: String) = datasetVersion(JsonField.of(datasetVersion)) - - /** - * Version number of the linked dataset the experiment was run against. This can be used to - * reproduce the experiment after the dataset has been modified. - */ - @JsonProperty("dataset_version") - @ExcludeMissing - fun datasetVersion(datasetVersion: JsonField) = apply { - this.datasetVersion = datasetVersion - } - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ - fun public_(public_: Boolean) = public_(JsonField.of(public_)) - - /** - * Whether or not the experiment is public. Public experiments can be viewed by anybody - * inside or outside the organization - */ - @JsonProperty("public") - @ExcludeMissing - fun public_(public_: JsonField) = apply { this.public_ = public_ } - - /** User-controlled metadata about the experiment */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** User-controlled metadata about the experiment */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchExperiment = - PatchExperiment( - name, - description, - repoInfo, - baseExpId, - datasetId, - datasetVersion, - public_, - metadata, - additionalProperties.toUnmodifiable(), - ) - } - - /** User-controlled metadata about the experiment */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchFunction.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchFunction.kt deleted file mode 100755 index f7937658..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchFunction.kt +++ /dev/null @@ -1,1673 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(builder = PatchFunction.Builder::class) -@NoAutoDetect -class PatchFunction -private constructor( - private val name: JsonField, - private val description: JsonField, - private val promptData: JsonField, - private val functionData: JsonField, - private val tags: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the prompt */ - fun name(): String? = name.getNullable("name") - - /** Textual description of the prompt */ - fun description(): String? = description.getNullable("description") - - /** The prompt, model, and its parameters */ - fun promptData(): PromptData? = promptData.getNullable("prompt_data") - - fun functionData(): FunctionData? = functionData.getNullable("function_data") - - /** A list of tags for the prompt */ - fun tags(): List? = tags.getNullable("tags") - - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData - - @JsonProperty("function_data") @ExcludeMissing fun _functionData() = functionData - - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchFunction = apply { - if (!validated) { - name() - description() - promptData()?.validate() - functionData() - tags() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchFunction && - this.name == other.name && - this.description == other.description && - this.promptData == other.promptData && - this.functionData == other.functionData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - promptData, - functionData, - tags, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchFunction{name=$name, description=$description, promptData=$promptData, functionData=$functionData, tags=$tags, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var functionData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchFunction: PatchFunction) = apply { - this.name = patchFunction.name - this.description = patchFunction.description - this.promptData = patchFunction.promptData - this.functionData = patchFunction.functionData - this.tags = patchFunction.tags - additionalProperties(patchFunction.additionalProperties) - } - - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } - - fun functionData(functionData: FunctionData) = functionData(JsonField.of(functionData)) - - @JsonProperty("function_data") - @ExcludeMissing - fun functionData(functionData: JsonField) = apply { - this.functionData = functionData - } - - /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchFunction = - PatchFunction( - name, - description, - promptData, - functionData, - tags.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = FunctionData.Deserializer::class) - @JsonSerialize(using = FunctionData.Serializer::class) - 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, - ) { - - private var validated: Boolean = false - - fun prompt(): Prompt? = prompt - - fun code(): Code? = code - - fun global(): Global? = global - - fun nullableVariant(): NullableVariant? = nullableVariant - - fun isPrompt(): Boolean = prompt != null - - fun isCode(): Boolean = code != null - - fun isGlobal(): Boolean = global != null - - fun isNullableVariant(): Boolean = nullableVariant != null - - fun asPrompt(): Prompt = prompt.getOrThrow("prompt") - - fun asCode(): Code = code.getOrThrow("code") - - fun asGlobal(): Global = global.getOrThrow("global") - - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - - fun _json(): JsonValue? = _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) - } - } - - fun validate(): FunctionData = apply { - if (!validated) { - if (prompt == null && code == null && global == null && nullableVariant == null) { - throw BraintrustInvalidDataException("Unknown FunctionData: $_json") - } - prompt?.validate() - code?.validate() - global?.validate() - nullableVariant?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FunctionData && - this.prompt == other.prompt && - this.code == other.code && - this.global == other.global && - this.nullableVariant == other.nullableVariant - } - - override fun hashCode(): Int { - return Objects.hash( - prompt, - code, - global, - nullableVariant, - ) - } - - override fun toString(): String { - return when { - prompt != null -> "FunctionData{prompt=$prompt}" - code != null -> "FunctionData{code=$code}" - global != null -> "FunctionData{global=$global}" - nullableVariant != null -> "FunctionData{nullableVariant=$nullableVariant}" - _json != null -> "FunctionData{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionData") - } - } - - companion object { - - fun ofPrompt(prompt: Prompt) = FunctionData(prompt = prompt) - - fun ofCode(code: Code) = FunctionData(code = code) - - fun ofGlobal(global: Global) = FunctionData(global = global) - - fun ofNullableVariant(nullableVariant: NullableVariant) = - FunctionData(nullableVariant = nullableVariant) - } - - interface Visitor { - - fun visitPrompt(prompt: Prompt): T - - fun visitCode(code: Code): T - - fun visitGlobal(global: Global): T - - fun visitNullableVariant(nullableVariant: NullableVariant): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionData: $json") - } - } - - 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) - } - } - - 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") - } - } - } - - @JsonDeserialize(builder = Prompt.Builder::class) - @NoAutoDetect - class Prompt - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Prompt = apply { - if (!validated) { - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Prompt{type=$type, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(prompt: Prompt) = apply { - this.type = prompt.type - additionalProperties(prompt.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Prompt = Prompt(type, additionalProperties.toUnmodifiable()) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val PROMPT = Type(JsonField.of("prompt")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - PROMPT, - } - - enum class Value { - PROMPT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PROMPT -> Value.PROMPT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PROMPT -> Known.PROMPT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = Code.Builder::class) - @NoAutoDetect - class Code - private constructor( - private val type: JsonField, - private val data: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun data(): Data = data.getRequired("data") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("data") @ExcludeMissing fun _data() = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Code = apply { - if (!validated) { - type() - data().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Code && - this.type == other.type && - this.data == other.data && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - data, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Code{type=$type, data=$data, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(code: Code) = apply { - this.type = code.type - this.data = code.data - additionalProperties(code.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun data(data: Data) = data(JsonField.of(data)) - - @JsonProperty("data") - @ExcludeMissing - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Code = - Code( - type, - data, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Data.Builder::class) - @NoAutoDetect - class Data - private constructor( - private val runtimeContext: JsonField, - private val location: JsonField, - private val bundleId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun runtimeContext(): RuntimeContext = runtimeContext.getRequired("runtime_context") - - fun location(): Location = location.getRequired("location") - - fun bundleId(): String = bundleId.getRequired("bundle_id") - - @JsonProperty("runtime_context") - @ExcludeMissing - fun _runtimeContext() = runtimeContext - - @JsonProperty("location") @ExcludeMissing fun _location() = location - - @JsonProperty("bundle_id") @ExcludeMissing fun _bundleId() = bundleId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Data = apply { - if (!validated) { - runtimeContext().validate() - location().validate() - bundleId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && - this.runtimeContext == other.runtimeContext && - this.location == other.location && - this.bundleId == other.bundleId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtimeContext, - location, - bundleId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Data{runtimeContext=$runtimeContext, location=$location, bundleId=$bundleId, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var runtimeContext: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var bundleId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(data: Data) = apply { - this.runtimeContext = data.runtimeContext - this.location = data.location - this.bundleId = data.bundleId - additionalProperties(data.additionalProperties) - } - - fun runtimeContext(runtimeContext: RuntimeContext) = - runtimeContext(JsonField.of(runtimeContext)) - - @JsonProperty("runtime_context") - @ExcludeMissing - fun runtimeContext(runtimeContext: JsonField) = apply { - this.runtimeContext = runtimeContext - } - - fun location(location: Location) = location(JsonField.of(location)) - - @JsonProperty("location") - @ExcludeMissing - fun location(location: JsonField) = apply { this.location = location } - - fun bundleId(bundleId: String) = bundleId(JsonField.of(bundleId)) - - @JsonProperty("bundle_id") - @ExcludeMissing - fun bundleId(bundleId: JsonField) = apply { this.bundleId = bundleId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Data = - Data( - runtimeContext, - location, - bundleId, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Location.Builder::class) - @NoAutoDetect - class Location - private constructor( - private val type: JsonField, - private val evalName: JsonField, - private val position: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun evalName(): String = evalName.getRequired("eval_name") - - fun position(): Position = position.getRequired("position") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("eval_name") @ExcludeMissing fun _evalName() = evalName - - @JsonProperty("position") @ExcludeMissing fun _position() = position - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Location = apply { - if (!validated) { - type() - evalName() - position() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - this.type == other.type && - this.evalName == other.evalName && - this.position == other.position && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - evalName, - position, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Location{type=$type, evalName=$evalName, position=$position, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var evalName: JsonField = JsonMissing.of() - private var position: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(location: Location) = apply { - this.type = location.type - this.evalName = location.evalName - this.position = location.position - additionalProperties(location.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun evalName(evalName: String) = evalName(JsonField.of(evalName)) - - @JsonProperty("eval_name") - @ExcludeMissing - fun evalName(evalName: JsonField) = apply { - this.evalName = evalName - } - - fun position(position: Position) = position(JsonField.of(position)) - - @JsonProperty("position") - @ExcludeMissing - fun position(position: JsonField) = apply { - this.position = position - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Location = - Location( - type, - evalName, - position, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Position.Deserializer::class) - @JsonSerialize(using = Position.Serializer::class) - class Position - private constructor( - private val task: Task? = null, - private val score: Score? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun task(): Task? = task - - fun score(): Score? = score - - fun isTask(): Boolean = task != null - - fun isScore(): Boolean = score != null - - fun asTask(): Task = task.getOrThrow("task") - - fun asScore(): Score = score.getOrThrow("score") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - task != null -> visitor.visitTask(task) - score != null -> visitor.visitScore(score) - else -> visitor.unknown(_json) - } - } - - fun validate(): Position = apply { - if (!validated) { - if (task == null && score == null) { - throw BraintrustInvalidDataException("Unknown Position: $_json") - } - score?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Position && - this.task == other.task && - this.score == other.score - } - - override fun hashCode(): Int { - return Objects.hash(task, score) - } - - override fun toString(): String { - return when { - task != null -> "Position{task=$task}" - score != null -> "Position{score=$score}" - _json != null -> "Position{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Position") - } - } - - companion object { - - fun ofTask(task: Task) = Position(task = task) - - fun ofScore(score: Score) = Position(score = score) - } - - interface Visitor { - - fun visitTask(task: Task): T - - fun visitScore(score: Score): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Position: $json") - } - } - - class Deserializer : BaseDeserializer(Position::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Position { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Position(task = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Position(score = it, _json = json) - } - - return Position(_json = json) - } - } - - class Serializer : BaseSerializer(Position::class) { - - override fun serialize( - value: Position, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.task != null -> generator.writeObject(value.task) - value.score != null -> generator.writeObject(value.score) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Position") - } - } - } - - class Task - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Task && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val TASK = Task(JsonField.of("task")) - - fun of(value: String) = Task(JsonField.of(value)) - } - - enum class Known { - TASK, - } - - enum class Value { - TASK, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TASK -> Value.TASK - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TASK -> Known.TASK - else -> - throw BraintrustInvalidDataException("Unknown Task: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - @JsonDeserialize(builder = Score.Builder::class) - @NoAutoDetect - class Score - private constructor( - private val score: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun score(): Double = score.getRequired("score") - - @JsonProperty("score") @ExcludeMissing fun _score() = score - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun validate(): Score = apply { - if (!validated) { - score() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Score && - this.score == other.score && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(score, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Score{score=$score, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var score: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(score: Score) = apply { - this.score = score.score - additionalProperties(score.additionalProperties) - } - - fun score(score: Double) = score(JsonField.of(score)) - - @JsonProperty("score") - @ExcludeMissing - fun score(score: JsonField) = apply { this.score = score } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): Score = - Score(score, additionalProperties.toUnmodifiable()) - } - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val EXPERIMENT = Type(JsonField.of("experiment")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - EXPERIMENT, - } - - enum class Value { - EXPERIMENT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - EXPERIMENT -> Value.EXPERIMENT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - EXPERIMENT -> Known.EXPERIMENT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = RuntimeContext.Builder::class) - @NoAutoDetect - class RuntimeContext - private constructor( - private val runtime: JsonField, - private val version: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun runtime(): Runtime = runtime.getRequired("runtime") - - fun version(): String = version.getRequired("version") - - @JsonProperty("runtime") @ExcludeMissing fun _runtime() = runtime - - @JsonProperty("version") @ExcludeMissing fun _version() = version - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): RuntimeContext = apply { - if (!validated) { - runtime() - version() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RuntimeContext && - this.runtime == other.runtime && - this.version == other.version && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - runtime, - version, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RuntimeContext{runtime=$runtime, version=$version, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var runtime: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - internal fun from(runtimeContext: RuntimeContext) = apply { - this.runtime = runtimeContext.runtime - this.version = runtimeContext.version - additionalProperties(runtimeContext.additionalProperties) - } - - fun runtime(runtime: Runtime) = runtime(JsonField.of(runtime)) - - @JsonProperty("runtime") - @ExcludeMissing - fun runtime(runtime: JsonField) = apply { this.runtime = runtime } - - fun version(version: String) = version(JsonField.of(version)) - - @JsonProperty("version") - @ExcludeMissing - fun version(version: JsonField) = apply { this.version = version } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun build(): RuntimeContext = - RuntimeContext( - runtime, - version, - additionalProperties.toUnmodifiable(), - ) - } - - class Runtime - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Runtime && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val NODE = Runtime(JsonField.of("node")) - - fun of(value: String) = Runtime(JsonField.of(value)) - } - - enum class Known { - NODE, - } - - enum class Value { - NODE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - NODE -> Value.NODE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - NODE -> Known.NODE - else -> - throw BraintrustInvalidDataException("Unknown Runtime: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val CODE = Type(JsonField.of("code")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - CODE, - } - - enum class Value { - CODE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CODE -> Value.CODE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CODE -> Known.CODE - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = Global.Builder::class) - @NoAutoDetect - class Global - private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun type(): Type = type.getRequired("type") - - fun name(): String = name.getRequired("name") - - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Global = apply { - if (!validated) { - type() - name() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var type: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(global: Global) = apply { - this.type = global.type - this.name = global.name - additionalProperties(global.additionalProperties) - } - - fun type(type: Type) = type(JsonField.of(type)) - - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Global = - Global( - type, - name, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val GLOBAL = Type(JsonField.of("global")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - GLOBAL, - } - - enum class Value { - GLOBAL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = NullableVariant.Builder::class) - @NoAutoDetect - class NullableVariant - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): NullableVariant = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NullableVariant && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchGroup.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchGroup.kt deleted file mode 100755 index ce1593b4..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchGroup.kt +++ /dev/null @@ -1,236 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = PatchGroup.Builder::class) -@NoAutoDetect -class PatchGroup -private constructor( - private val description: JsonField, - private val name: JsonField, - private val addMemberUsers: JsonField>, - private val removeMemberUsers: JsonField>, - private val addMemberGroups: JsonField>, - private val removeMemberGroups: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Textual description of the group */ - fun description(): String? = description.getNullable("description") - - /** Name of the group */ - fun name(): String? = name.getNullable("name") - - /** A list of user IDs to add to the group */ - fun addMemberUsers(): List? = addMemberUsers.getNullable("add_member_users") - - /** A list of user IDs to remove from the group */ - fun removeMemberUsers(): List? = removeMemberUsers.getNullable("remove_member_users") - - /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(): List? = addMemberGroups.getNullable("add_member_groups") - - /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(): List? = removeMemberGroups.getNullable("remove_member_groups") - - /** Textual description of the group */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Name of the group */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** A list of user IDs to add to the group */ - @JsonProperty("add_member_users") @ExcludeMissing fun _addMemberUsers() = addMemberUsers - - /** A list of user IDs to remove from the group */ - @JsonProperty("remove_member_users") - @ExcludeMissing - fun _removeMemberUsers() = removeMemberUsers - - /** A list of group IDs to add to the group's inheriting-from set */ - @JsonProperty("add_member_groups") @ExcludeMissing fun _addMemberGroups() = addMemberGroups - - /** A list of group IDs to remove from the group's inheriting-from set */ - @JsonProperty("remove_member_groups") - @ExcludeMissing - fun _removeMemberGroups() = removeMemberGroups - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchGroup = apply { - if (!validated) { - description() - name() - addMemberUsers() - removeMemberUsers() - addMemberGroups() - removeMemberGroups() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchGroup && - this.description == other.description && - this.name == other.name && - this.addMemberUsers == other.addMemberUsers && - this.removeMemberUsers == other.removeMemberUsers && - this.addMemberGroups == other.addMemberGroups && - this.removeMemberGroups == other.removeMemberGroups && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - description, - name, - addMemberUsers, - removeMemberUsers, - addMemberGroups, - removeMemberGroups, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchGroup{description=$description, name=$name, addMemberUsers=$addMemberUsers, removeMemberUsers=$removeMemberUsers, addMemberGroups=$addMemberGroups, removeMemberGroups=$removeMemberGroups, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var description: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var addMemberUsers: JsonField> = JsonMissing.of() - private var removeMemberUsers: JsonField> = JsonMissing.of() - private var addMemberGroups: JsonField> = JsonMissing.of() - private var removeMemberGroups: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchGroup: PatchGroup) = apply { - this.description = patchGroup.description - this.name = patchGroup.name - this.addMemberUsers = patchGroup.addMemberUsers - this.removeMemberUsers = patchGroup.removeMemberUsers - this.addMemberGroups = patchGroup.addMemberGroups - this.removeMemberGroups = patchGroup.removeMemberGroups - additionalProperties(patchGroup.additionalProperties) - } - - /** Textual description of the group */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the group */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Name of the group */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the group */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** A list of user IDs to add to the group */ - fun addMemberUsers(addMemberUsers: List) = - addMemberUsers(JsonField.of(addMemberUsers)) - - /** A list of user IDs to add to the group */ - @JsonProperty("add_member_users") - @ExcludeMissing - fun addMemberUsers(addMemberUsers: JsonField>) = apply { - this.addMemberUsers = addMemberUsers - } - - /** A list of user IDs to remove from the group */ - fun removeMemberUsers(removeMemberUsers: List) = - removeMemberUsers(JsonField.of(removeMemberUsers)) - - /** A list of user IDs to remove from the group */ - @JsonProperty("remove_member_users") - @ExcludeMissing - fun removeMemberUsers(removeMemberUsers: JsonField>) = apply { - this.removeMemberUsers = removeMemberUsers - } - - /** A list of group IDs to add to the group's inheriting-from set */ - fun addMemberGroups(addMemberGroups: List) = - addMemberGroups(JsonField.of(addMemberGroups)) - - /** A list of group IDs to add to the group's inheriting-from set */ - @JsonProperty("add_member_groups") - @ExcludeMissing - fun addMemberGroups(addMemberGroups: JsonField>) = apply { - this.addMemberGroups = addMemberGroups - } - - /** A list of group IDs to remove from the group's inheriting-from set */ - fun removeMemberGroups(removeMemberGroups: List) = - removeMemberGroups(JsonField.of(removeMemberGroups)) - - /** A list of group IDs to remove from the group's inheriting-from set */ - @JsonProperty("remove_member_groups") - @ExcludeMissing - fun removeMemberGroups(removeMemberGroups: JsonField>) = apply { - this.removeMemberGroups = removeMemberGroups - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchGroup = - PatchGroup( - description, - name, - addMemberUsers.map { it.toUnmodifiable() }, - removeMemberUsers.map { it.toUnmodifiable() }, - addMemberGroups.map { it.toUnmodifiable() }, - removeMemberGroups.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganization.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganization.kt deleted file mode 100755 index 9f103ade..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganization.kt +++ /dev/null @@ -1,185 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = PatchOrganization.Builder::class) -@NoAutoDetect -class PatchOrganization -private constructor( - private val name: JsonField, - private val apiUrl: JsonField, - private val isUniversalApi: JsonField, - private val proxyUrl: JsonField, - private val realtimeUrl: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the organization */ - fun name(): String? = name.getNullable("name") - - fun apiUrl(): String? = apiUrl.getNullable("api_url") - - fun isUniversalApi(): Boolean? = isUniversalApi.getNullable("is_universal_api") - - fun proxyUrl(): String? = proxyUrl.getNullable("proxy_url") - - fun realtimeUrl(): String? = realtimeUrl.getNullable("realtime_url") - - /** Name of the organization */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("api_url") @ExcludeMissing fun _apiUrl() = apiUrl - - @JsonProperty("is_universal_api") @ExcludeMissing fun _isUniversalApi() = isUniversalApi - - @JsonProperty("proxy_url") @ExcludeMissing fun _proxyUrl() = proxyUrl - - @JsonProperty("realtime_url") @ExcludeMissing fun _realtimeUrl() = realtimeUrl - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchOrganization = apply { - if (!validated) { - name() - apiUrl() - isUniversalApi() - proxyUrl() - realtimeUrl() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchOrganization && - this.name == other.name && - this.apiUrl == other.apiUrl && - this.isUniversalApi == other.isUniversalApi && - this.proxyUrl == other.proxyUrl && - this.realtimeUrl == other.realtimeUrl && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - apiUrl, - isUniversalApi, - proxyUrl, - realtimeUrl, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchOrganization{name=$name, apiUrl=$apiUrl, isUniversalApi=$isUniversalApi, proxyUrl=$proxyUrl, realtimeUrl=$realtimeUrl, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var apiUrl: JsonField = JsonMissing.of() - private var isUniversalApi: JsonField = JsonMissing.of() - private var proxyUrl: JsonField = JsonMissing.of() - private var realtimeUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchOrganization: PatchOrganization) = apply { - this.name = patchOrganization.name - this.apiUrl = patchOrganization.apiUrl - this.isUniversalApi = patchOrganization.isUniversalApi - this.proxyUrl = patchOrganization.proxyUrl - this.realtimeUrl = patchOrganization.realtimeUrl - additionalProperties(patchOrganization.additionalProperties) - } - - /** Name of the organization */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the organization */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun apiUrl(apiUrl: String) = apiUrl(JsonField.of(apiUrl)) - - @JsonProperty("api_url") - @ExcludeMissing - fun apiUrl(apiUrl: JsonField) = apply { this.apiUrl = apiUrl } - - fun isUniversalApi(isUniversalApi: Boolean) = isUniversalApi(JsonField.of(isUniversalApi)) - - @JsonProperty("is_universal_api") - @ExcludeMissing - fun isUniversalApi(isUniversalApi: JsonField) = apply { - this.isUniversalApi = isUniversalApi - } - - fun proxyUrl(proxyUrl: String) = proxyUrl(JsonField.of(proxyUrl)) - - @JsonProperty("proxy_url") - @ExcludeMissing - fun proxyUrl(proxyUrl: JsonField) = apply { this.proxyUrl = proxyUrl } - - fun realtimeUrl(realtimeUrl: String) = realtimeUrl(JsonField.of(realtimeUrl)) - - @JsonProperty("realtime_url") - @ExcludeMissing - fun realtimeUrl(realtimeUrl: JsonField) = apply { this.realtimeUrl = realtimeUrl } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchOrganization = - PatchOrganization( - name, - apiUrl, - isUniversalApi, - proxyUrl, - realtimeUrl, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembers.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembers.kt deleted file mode 100755 index 12ffce3e..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchOrganizationMembers.kt +++ /dev/null @@ -1,550 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = PatchOrganizationMembers.Builder::class) -@NoAutoDetect -class PatchOrganizationMembers -private constructor( - private val inviteUsers: JsonField, - private val removeUsers: JsonField, - private val orgName: JsonField, - private val orgId: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Users to invite to the organization */ - fun inviteUsers(): InviteUsers? = inviteUsers.getNullable("invite_users") - - /** Users to remove from the organization */ - fun removeUsers(): RemoveUsers? = removeUsers.getNullable("remove_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 name of the organization. - */ - fun orgName(): String? = orgName.getNullable("org_name") - - /** - * 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(): String? = orgId.getNullable("org_id") - - /** Users to invite to the organization */ - @JsonProperty("invite_users") @ExcludeMissing fun _inviteUsers() = inviteUsers - - /** Users to remove from the organization */ - @JsonProperty("remove_users") @ExcludeMissing fun _removeUsers() = removeUsers - - /** - * 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() = 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 id of the organization. - */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchOrganizationMembers = apply { - if (!validated) { - inviteUsers()?.validate() - removeUsers()?.validate() - orgName() - orgId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchOrganizationMembers && - this.inviteUsers == other.inviteUsers && - this.removeUsers == other.removeUsers && - this.orgName == other.orgName && - this.orgId == other.orgId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - inviteUsers, - removeUsers, - orgName, - orgId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchOrganizationMembers{inviteUsers=$inviteUsers, removeUsers=$removeUsers, orgName=$orgName, orgId=$orgId, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var inviteUsers: JsonField = JsonMissing.of() - private var removeUsers: JsonField = JsonMissing.of() - private var orgName: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchOrganizationMembers: PatchOrganizationMembers) = apply { - this.inviteUsers = patchOrganizationMembers.inviteUsers - this.removeUsers = patchOrganizationMembers.removeUsers - this.orgName = patchOrganizationMembers.orgName - this.orgId = patchOrganizationMembers.orgId - additionalProperties(patchOrganizationMembers.additionalProperties) - } - - /** Users to invite to the organization */ - fun inviteUsers(inviteUsers: InviteUsers) = inviteUsers(JsonField.of(inviteUsers)) - - /** Users to invite to the organization */ - @JsonProperty("invite_users") - @ExcludeMissing - fun inviteUsers(inviteUsers: JsonField) = apply { - this.inviteUsers = inviteUsers - } - - /** Users to remove from the organization */ - fun removeUsers(removeUsers: RemoveUsers) = removeUsers(JsonField.of(removeUsers)) - - /** Users to remove from the organization */ - @JsonProperty("remove_users") - @ExcludeMissing - fun removeUsers(removeUsers: JsonField) = apply { - this.removeUsers = removeUsers - } - - /** - * 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.of(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. - */ - @JsonProperty("org_name") - @ExcludeMissing - fun orgName(orgName: JsonField) = apply { this.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 id of the organization. - */ - fun orgId(orgId: String) = orgId(JsonField.of(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. - */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchOrganizationMembers = - PatchOrganizationMembers( - inviteUsers, - removeUsers, - orgName, - orgId, - additionalProperties.toUnmodifiable(), - ) - } - - /** Users to invite to the organization */ - @JsonDeserialize(builder = InviteUsers.Builder::class) - @NoAutoDetect - class InviteUsers - private constructor( - private val ids: JsonField>, - private val emails: JsonField>, - private val sendInviteEmails: JsonField, - private val groupId: JsonField, - private val groupName: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Ids of existing users to invite */ - fun ids(): List? = ids.getNullable("ids") - - /** Emails of users to invite */ - fun emails(): List? = emails.getNullable("emails") - - /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(): Boolean? = sendInviteEmails.getNullable("send_invite_emails") - - /** - * Optional id of a group to add newly-invited users to. Cannot specify both a group id and - * a group name. - */ - fun groupId(): String? = groupId.getNullable("group_id") - - /** - * Optional name of a group to add newly-invited users to. Cannot specify both a group id - * and a group name. - */ - fun groupName(): String? = groupName.getNullable("group_name") - - /** Ids of existing users to invite */ - @JsonProperty("ids") @ExcludeMissing fun _ids() = ids - - /** Emails of users to invite */ - @JsonProperty("emails") @ExcludeMissing fun _emails() = emails - - /** If true, send invite emails to the users who wore actually added */ - @JsonProperty("send_invite_emails") - @ExcludeMissing - fun _sendInviteEmails() = sendInviteEmails - - /** - * Optional id of a group to add newly-invited users to. Cannot specify both a group id and - * a group name. - */ - @JsonProperty("group_id") @ExcludeMissing fun _groupId() = groupId - - /** - * Optional name of a group to add newly-invited users to. Cannot specify both a group id - * and a group name. - */ - @JsonProperty("group_name") @ExcludeMissing fun _groupName() = groupName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InviteUsers = apply { - if (!validated) { - ids() - emails() - sendInviteEmails() - groupId() - groupName() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InviteUsers && - this.ids == other.ids && - this.emails == other.emails && - this.sendInviteEmails == other.sendInviteEmails && - this.groupId == other.groupId && - this.groupName == other.groupName && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - ids, - emails, - sendInviteEmails, - groupId, - groupName, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "InviteUsers{ids=$ids, emails=$emails, sendInviteEmails=$sendInviteEmails, groupId=$groupId, groupName=$groupName, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var ids: JsonField> = JsonMissing.of() - private var emails: JsonField> = JsonMissing.of() - private var sendInviteEmails: JsonField = JsonMissing.of() - private var groupId: JsonField = JsonMissing.of() - private var groupName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(inviteUsers: InviteUsers) = apply { - this.ids = inviteUsers.ids - this.emails = inviteUsers.emails - this.sendInviteEmails = inviteUsers.sendInviteEmails - this.groupId = inviteUsers.groupId - this.groupName = inviteUsers.groupName - additionalProperties(inviteUsers.additionalProperties) - } - - /** Ids of existing users to invite */ - fun ids(ids: List) = ids(JsonField.of(ids)) - - /** Ids of existing users to invite */ - @JsonProperty("ids") - @ExcludeMissing - fun ids(ids: JsonField>) = apply { this.ids = ids } - - /** Emails of users to invite */ - fun emails(emails: List) = emails(JsonField.of(emails)) - - /** Emails of users to invite */ - @JsonProperty("emails") - @ExcludeMissing - fun emails(emails: JsonField>) = apply { this.emails = emails } - - /** If true, send invite emails to the users who wore actually added */ - fun sendInviteEmails(sendInviteEmails: Boolean) = - sendInviteEmails(JsonField.of(sendInviteEmails)) - - /** If true, send invite emails to the users who wore actually added */ - @JsonProperty("send_invite_emails") - @ExcludeMissing - fun sendInviteEmails(sendInviteEmails: JsonField) = apply { - this.sendInviteEmails = sendInviteEmails - } - - /** - * Optional id of a group to add newly-invited users to. Cannot specify both a group id - * and a group name. - */ - fun groupId(groupId: String) = groupId(JsonField.of(groupId)) - - /** - * Optional id of a group to add newly-invited users to. Cannot specify both a group id - * and a group name. - */ - @JsonProperty("group_id") - @ExcludeMissing - fun groupId(groupId: JsonField) = apply { this.groupId = groupId } - - /** - * Optional name of a group to add newly-invited users to. Cannot specify both a group - * id and a group name. - */ - fun groupName(groupName: String) = groupName(JsonField.of(groupName)) - - /** - * Optional name of a group to add newly-invited users to. Cannot specify both a group - * id and a group name. - */ - @JsonProperty("group_name") - @ExcludeMissing - fun groupName(groupName: JsonField) = apply { this.groupName = groupName } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InviteUsers = - InviteUsers( - ids.map { it.toUnmodifiable() }, - emails.map { it.toUnmodifiable() }, - sendInviteEmails, - groupId, - groupName, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** Users to remove from the organization */ - @JsonDeserialize(builder = RemoveUsers.Builder::class) - @NoAutoDetect - class RemoveUsers - private constructor( - private val ids: JsonField>, - private val emails: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Ids of users to remove */ - fun ids(): List? = ids.getNullable("ids") - - /** Emails of users to remove */ - fun emails(): List? = emails.getNullable("emails") - - /** Ids of users to remove */ - @JsonProperty("ids") @ExcludeMissing fun _ids() = ids - - /** Emails of users to remove */ - @JsonProperty("emails") @ExcludeMissing fun _emails() = emails - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): RemoveUsers = apply { - if (!validated) { - ids() - emails() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveUsers && - this.ids == other.ids && - this.emails == other.emails && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - ids, - emails, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RemoveUsers{ids=$ids, emails=$emails, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var ids: JsonField> = JsonMissing.of() - private var emails: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(removeUsers: RemoveUsers) = apply { - this.ids = removeUsers.ids - this.emails = removeUsers.emails - additionalProperties(removeUsers.additionalProperties) - } - - /** Ids of users to remove */ - fun ids(ids: List) = ids(JsonField.of(ids)) - - /** Ids of users to remove */ - @JsonProperty("ids") - @ExcludeMissing - fun ids(ids: JsonField>) = apply { this.ids = ids } - - /** Emails of users to remove */ - fun emails(emails: List) = emails(JsonField.of(emails)) - - /** Emails of users to remove */ - @JsonProperty("emails") - @ExcludeMissing - fun emails(emails: JsonField>) = apply { this.emails = emails } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): RemoveUsers = - RemoveUsers( - ids.map { it.toUnmodifiable() }, - emails.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProject.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProject.kt deleted file mode 100755 index b1b9cd91..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProject.kt +++ /dev/null @@ -1,246 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = PatchProject.Builder::class) -@NoAutoDetect -class PatchProject -private constructor( - private val name: JsonField, - private val settings: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the project */ - fun name(): String? = name.getNullable("name") - - /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. - */ - fun settings(): Settings? = settings.getNullable("settings") - - /** Name of the project */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. - */ - @JsonProperty("settings") @ExcludeMissing fun _settings() = settings - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchProject = apply { - if (!validated) { - name() - settings()?.validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchProject && - this.name == other.name && - this.settings == other.settings && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - settings, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchProject{name=$name, settings=$settings, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var settings: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchProject: PatchProject) = apply { - this.name = patchProject.name - this.settings = patchProject.settings - additionalProperties(patchProject.additionalProperties) - } - - /** Name of the project */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the project */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. - */ - fun settings(settings: Settings) = settings(JsonField.of(settings)) - - /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. - */ - @JsonProperty("settings") - @ExcludeMissing - fun settings(settings: JsonField) = apply { this.settings = settings } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchProject = - PatchProject( - name, - settings, - additionalProperties.toUnmodifiable(), - ) - } - - /** - * Project settings. Patch operations replace all settings, so make sure you include all - * settings you want to keep. - */ - @JsonDeserialize(builder = Settings.Builder::class) - @NoAutoDetect - class Settings - private constructor( - private val comparisonKey: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(): String? = comparisonKey.getNullable("comparison_key") - - /** The key used to join two experiments (defaults to `input`). */ - @JsonProperty("comparison_key") @ExcludeMissing fun _comparisonKey() = comparisonKey - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Settings = apply { - if (!validated) { - comparisonKey() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Settings && - this.comparisonKey == other.comparisonKey && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(comparisonKey, additionalProperties) - } - return hashCode - } - - override fun toString() = - "Settings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var comparisonKey: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(settings: Settings) = apply { - this.comparisonKey = settings.comparisonKey - additionalProperties(settings.additionalProperties) - } - - /** The key used to join two experiments (defaults to `input`). */ - fun comparisonKey(comparisonKey: String) = comparisonKey(JsonField.of(comparisonKey)) - - /** The key used to join two experiments (defaults to `input`). */ - @JsonProperty("comparison_key") - @ExcludeMissing - fun comparisonKey(comparisonKey: JsonField) = apply { - this.comparisonKey = comparisonKey - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Settings = Settings(comparisonKey, additionalProperties.toUnmodifiable()) - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectScore.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectScore.kt deleted file mode 100755 index 7d841093..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectScore.kt +++ /dev/null @@ -1,578 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(builder = PatchProjectScore.Builder::class) -@NoAutoDetect -class PatchProjectScore -private constructor( - private val name: JsonField, - private val description: JsonField, - private val scoreType: JsonField, - private val categories: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the project score */ - fun name(): String? = name.getNullable("name") - - /** Textual description of the project score */ - fun description(): String? = description.getNullable("description") - - /** The type of the configured score */ - fun scoreType(): ScoreType? = scoreType.getNullable("score_type") - - fun categories(): Categories? = categories.getNullable("categories") - - /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the project score */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The type of the configured score */ - @JsonProperty("score_type") @ExcludeMissing fun _scoreType() = scoreType - - @JsonProperty("categories") @ExcludeMissing fun _categories() = categories - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchProjectScore = apply { - if (!validated) { - name() - description() - scoreType() - categories() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchProjectScore && - this.name == other.name && - this.description == other.description && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - scoreType, - categories, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchProjectScore{name=$name, description=$description, scoreType=$scoreType, categories=$categories, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var scoreType: JsonField = JsonMissing.of() - private var categories: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchProjectScore: PatchProjectScore) = apply { - this.name = patchProjectScore.name - this.description = patchProjectScore.description - this.scoreType = patchProjectScore.scoreType - this.categories = patchProjectScore.categories - additionalProperties(patchProjectScore.additionalProperties) - } - - /** Name of the project score */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the project score */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the project score */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the project score */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) - - /** The type of the configured score */ - @JsonProperty("score_type") - @ExcludeMissing - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } - - fun categories(categories: Categories) = categories(JsonField.of(categories)) - - @JsonProperty("categories") - @ExcludeMissing - fun categories(categories: JsonField) = apply { this.categories = categories } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchProjectScore = - PatchProjectScore( - name, - description, - scoreType, - categories, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(using = Categories.Deserializer::class) - @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( - private val projectScoreCategories: List? = null, - private val weighted: Weighted? = null, - private val strings: List? = null, - private val nullableVariant: NullableVariant? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - /** For categorical-type project scores, the list of all categories */ - fun projectScoreCategories(): List? = projectScoreCategories - /** For weighted-type project scores, the weights of each score */ - fun weighted(): Weighted? = weighted - /** For minimum-type project scores, the list of included scores */ - fun strings(): List? = strings - - fun nullableVariant(): NullableVariant? = nullableVariant - - fun isProjectScoreCategories(): Boolean = projectScoreCategories != null - - fun isWeighted(): Boolean = weighted != null - - fun isStrings(): Boolean = strings != null - - fun isNullableVariant(): Boolean = nullableVariant != null - - fun asProjectScoreCategories(): List = - projectScoreCategories.getOrThrow("projectScoreCategories") - - fun asWeighted(): Weighted = weighted.getOrThrow("weighted") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - projectScoreCategories != null -> - visitor.visitProjectScoreCategories(projectScoreCategories) - weighted != null -> visitor.visitWeighted(weighted) - strings != null -> visitor.visitStrings(strings) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } - } - - fun validate(): Categories = apply { - if (!validated) { - if ( - projectScoreCategories == null && - weighted == null && - strings == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - projectScoreCategories?.forEach { it.validate() } - weighted?.validate() - nullableVariant?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.weighted == other.weighted && - this.strings == other.strings && - this.nullableVariant == other.nullableVariant - } - - override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - weighted, - strings, - nullableVariant, - ) - } - - override fun toString(): String { - return when { - projectScoreCategories != null -> - "Categories{projectScoreCategories=$projectScoreCategories}" - weighted != null -> "Categories{weighted=$weighted}" - strings != null -> "Categories{strings=$strings}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" - _json != null -> "Categories{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Categories") - } - } - - companion object { - - fun ofProjectScoreCategories(projectScoreCategories: List) = - Categories(projectScoreCategories = projectScoreCategories) - - fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) - - fun ofStrings(strings: List) = Categories(strings = strings) - - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) - } - - interface Visitor { - - fun visitProjectScoreCategories(projectScoreCategories: List): T - - fun visitWeighted(weighted: Weighted): T - - fun visitStrings(strings: List): T - - fun visitNullableVariant(nullableVariant: NullableVariant): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") - } - } - - 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(projectScoreCategories = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(nullableVariant = it, _json = json) - } - - return Categories(_json = json) - } - } - - class Serializer : BaseSerializer(Categories::class) { - - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.projectScoreCategories != null -> - generator.writeObject(value.projectScoreCategories) - value.weighted != null -> generator.writeObject(value.weighted) - value.strings != null -> generator.writeObject(value.strings) - 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 */ - @JsonDeserialize(builder = Weighted.Builder::class) - @NoAutoDetect - class Weighted - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Weighted = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Weighted && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Weighted{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(weighted: Weighted) = apply { - additionalProperties(weighted.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) - } - } - - @JsonDeserialize(builder = NullableVariant.Builder::class) - @NoAutoDetect - class NullableVariant - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): NullableVariant = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NullableVariant && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(nullableVariant: NullableVariant) = apply { - additionalProperties(nullableVariant.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) - } - } - } - - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScoreType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val SLIDER = ScoreType(JsonField.of("slider")) - - val CATEGORICAL = ScoreType(JsonField.of("categorical")) - - val WEIGHTED = ScoreType(JsonField.of("weighted")) - - val MINIMUM = ScoreType(JsonField.of("minimum")) - - fun of(value: String) = ScoreType(JsonField.of(value)) - } - - enum class Known { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - } - - enum class Value { - SLIDER, - CATEGORICAL, - WEIGHTED, - MINIMUM, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectTag.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectTag.kt deleted file mode 100755 index 5b6e101d..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchProjectTag.kt +++ /dev/null @@ -1,157 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = PatchProjectTag.Builder::class) -@NoAutoDetect -class PatchProjectTag -private constructor( - private val name: JsonField, - private val description: JsonField, - private val color: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the project tag */ - fun name(): String? = name.getNullable("name") - - /** Textual description of the project tag */ - fun description(): String? = description.getNullable("description") - - /** Color of the tag for the UI */ - fun color(): String? = color.getNullable("color") - - /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the project tag */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color() = color - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchProjectTag = apply { - if (!validated) { - name() - description() - color() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchProjectTag && - this.name == other.name && - this.description == other.description && - this.color == other.color && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - color, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchProjectTag{name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var color: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchProjectTag: PatchProjectTag) = apply { - this.name = patchProjectTag.name - this.description = patchProjectTag.description - this.color = patchProjectTag.color - additionalProperties(patchProjectTag.additionalProperties) - } - - /** Name of the project tag */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the project tag */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the project tag */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the project tag */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Color of the tag for the UI */ - fun color(color: String) = color(JsonField.of(color)) - - /** Color of the tag for the UI */ - @JsonProperty("color") - @ExcludeMissing - fun color(color: JsonField) = apply { this.color = color } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchProjectTag = - PatchProjectTag( - name, - description, - color, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchPrompt.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchPrompt.kt deleted file mode 100755 index 1992dd06..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchPrompt.kt +++ /dev/null @@ -1,178 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = PatchPrompt.Builder::class) -@NoAutoDetect -class PatchPrompt -private constructor( - private val name: JsonField, - private val description: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the prompt */ - fun name(): String? = name.getNullable("name") - - /** Textual description of the prompt */ - fun description(): String? = description.getNullable("description") - - /** The prompt, model, and its parameters */ - fun promptData(): PromptData? = promptData.getNullable("prompt_data") - - /** A list of tags for the prompt */ - fun tags(): List? = tags.getNullable("tags") - - /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData - - /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchPrompt = apply { - if (!validated) { - name() - description() - promptData()?.validate() - tags() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchPrompt && - this.name == other.name && - this.description == other.description && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - promptData, - tags, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchPrompt{name=$name, description=$description, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var promptData: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchPrompt: PatchPrompt) = apply { - this.name = patchPrompt.name - this.description = patchPrompt.description - this.promptData = patchPrompt.promptData - this.tags = patchPrompt.tags - additionalProperties(patchPrompt.additionalProperties) - } - - /** Name of the prompt */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the prompt */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Textual description of the prompt */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the prompt */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) - - /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") - @ExcludeMissing - fun promptData(promptData: JsonField) = apply { this.promptData = promptData } - - /** A list of tags for the prompt */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags for the prompt */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchPrompt = - PatchPrompt( - name, - description, - promptData, - tags.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchRole.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchRole.kt deleted file mode 100755 index 6254028c..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchRole.kt +++ /dev/null @@ -1,949 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = PatchRole.Builder::class) -@NoAutoDetect -class PatchRole -private constructor( - private val description: JsonField, - private val name: JsonField, - private val addMemberPermissions: JsonField>, - private val removeMemberPermissions: JsonField>, - private val addMemberRoles: JsonField>, - private val removeMemberRoles: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Textual description of the role */ - fun description(): String? = description.getNullable("description") - - /** Name of the role */ - fun name(): String? = name.getNullable("name") - - /** A list of permissions to add to the role */ - fun addMemberPermissions(): List? = - addMemberPermissions.getNullable("add_member_permissions") - - /** A list of permissions to remove from the role */ - fun removeMemberPermissions(): List? = - removeMemberPermissions.getNullable("remove_member_permissions") - - /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(): List? = addMemberRoles.getNullable("add_member_roles") - - /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(): List? = removeMemberRoles.getNullable("remove_member_roles") - - /** Textual description of the role */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** A list of permissions to add to the role */ - @JsonProperty("add_member_permissions") - @ExcludeMissing - fun _addMemberPermissions() = addMemberPermissions - - /** A list of permissions to remove from the role */ - @JsonProperty("remove_member_permissions") - @ExcludeMissing - fun _removeMemberPermissions() = removeMemberPermissions - - /** A list of role IDs to add to the role's inheriting-from set */ - @JsonProperty("add_member_roles") @ExcludeMissing fun _addMemberRoles() = addMemberRoles - - /** A list of role IDs to remove from the role's inheriting-from set */ - @JsonProperty("remove_member_roles") - @ExcludeMissing - fun _removeMemberRoles() = removeMemberRoles - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchRole = apply { - if (!validated) { - description() - name() - addMemberPermissions()?.forEach { it.validate() } - removeMemberPermissions()?.forEach { it.validate() } - addMemberRoles() - removeMemberRoles() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchRole && - this.description == other.description && - this.name == other.name && - this.addMemberPermissions == other.addMemberPermissions && - this.removeMemberPermissions == other.removeMemberPermissions && - this.addMemberRoles == other.addMemberRoles && - this.removeMemberRoles == other.removeMemberRoles && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - description, - name, - addMemberPermissions, - removeMemberPermissions, - addMemberRoles, - removeMemberRoles, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchRole{description=$description, name=$name, addMemberPermissions=$addMemberPermissions, removeMemberPermissions=$removeMemberPermissions, addMemberRoles=$addMemberRoles, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var description: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var addMemberPermissions: JsonField> = JsonMissing.of() - private var removeMemberPermissions: JsonField> = - JsonMissing.of() - private var addMemberRoles: JsonField> = JsonMissing.of() - private var removeMemberRoles: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchRole: PatchRole) = apply { - this.description = patchRole.description - this.name = patchRole.name - this.addMemberPermissions = patchRole.addMemberPermissions - this.removeMemberPermissions = patchRole.removeMemberPermissions - this.addMemberRoles = patchRole.addMemberRoles - this.removeMemberRoles = patchRole.removeMemberRoles - additionalProperties(patchRole.additionalProperties) - } - - /** Textual description of the role */ - fun description(description: String) = description(JsonField.of(description)) - - /** Textual description of the role */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** Name of the role */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the role */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** A list of permissions to add to the role */ - fun addMemberPermissions(addMemberPermissions: List) = - addMemberPermissions(JsonField.of(addMemberPermissions)) - - /** A list of permissions to add to the role */ - @JsonProperty("add_member_permissions") - @ExcludeMissing - fun addMemberPermissions(addMemberPermissions: JsonField>) = - apply { - this.addMemberPermissions = addMemberPermissions - } - - /** A list of permissions to remove from the role */ - fun removeMemberPermissions(removeMemberPermissions: List) = - removeMemberPermissions(JsonField.of(removeMemberPermissions)) - - /** A list of permissions to remove from the role */ - @JsonProperty("remove_member_permissions") - @ExcludeMissing - fun removeMemberPermissions( - removeMemberPermissions: JsonField> - ) = apply { this.removeMemberPermissions = removeMemberPermissions } - - /** A list of role IDs to add to the role's inheriting-from set */ - fun addMemberRoles(addMemberRoles: List) = - addMemberRoles(JsonField.of(addMemberRoles)) - - /** A list of role IDs to add to the role's inheriting-from set */ - @JsonProperty("add_member_roles") - @ExcludeMissing - fun addMemberRoles(addMemberRoles: JsonField>) = apply { - this.addMemberRoles = addMemberRoles - } - - /** A list of role IDs to remove from the role's inheriting-from set */ - fun removeMemberRoles(removeMemberRoles: List) = - removeMemberRoles(JsonField.of(removeMemberRoles)) - - /** A list of role IDs to remove from the role's inheriting-from set */ - @JsonProperty("remove_member_roles") - @ExcludeMissing - fun removeMemberRoles(removeMemberRoles: JsonField>) = apply { - this.removeMemberRoles = removeMemberRoles - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchRole = - PatchRole( - description, - name, - addMemberPermissions.map { it.toUnmodifiable() }, - removeMemberPermissions.map { it.toUnmodifiable() }, - addMemberRoles.map { it.toUnmodifiable() }, - removeMemberRoles.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = AddMemberPermission.Builder::class) - @NoAutoDetect - class AddMemberPermission - private constructor( - private val permission: JsonField, - private val restrictObjectType: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - fun permission(): Permission? = permission.getNullable("permission") - - /** The object type that the ACL applies to */ - fun restrictObjectType(): RestrictObjectType? = - restrictObjectType.getNullable("restrict_object_type") - - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - @JsonProperty("permission") @ExcludeMissing fun _permission() = permission - - /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - @ExcludeMissing - fun _restrictObjectType() = restrictObjectType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): AddMemberPermission = apply { - if (!validated) { - permission() - restrictObjectType() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddMemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var permission: JsonField = JsonMissing.of() - private var restrictObjectType: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(addMemberPermission: AddMemberPermission) = apply { - this.permission = addMemberPermission.permission - this.restrictObjectType = addMemberPermission.restrictObjectType - additionalProperties(addMemberPermission.additionalProperties) - } - - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles - */ - fun permission(permission: 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 - */ - @JsonProperty("permission") - @ExcludeMissing - fun permission(permission: JsonField) = apply { - this.permission = permission - } - - /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType) = - restrictObjectType(JsonField.of(restrictObjectType)) - - /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - @ExcludeMissing - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): AddMemberPermission = - AddMemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) - } - - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Permission && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val CREATE = Permission(JsonField.of("create")) - - val READ = Permission(JsonField.of("read")) - - val UPDATE = Permission(JsonField.of("update")) - - val DELETE = Permission(JsonField.of("delete")) - - val CREATE_ACLS = Permission(JsonField.of("create_acls")) - - val READ_ACLS = Permission(JsonField.of("read_acls")) - - val UPDATE_ACLS = Permission(JsonField.of("update_acls")) - - val DELETE_ACLS = Permission(JsonField.of("delete_acls")) - - fun of(value: String) = Permission(JsonField.of(value)) - } - - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - enum class Value { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RestrictObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val ORGANIZATION = RestrictObjectType(JsonField.of("organization")) - - val PROJECT = RestrictObjectType(JsonField.of("project")) - - val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) - - val DATASET = RestrictObjectType(JsonField.of("dataset")) - - val PROMPT = RestrictObjectType(JsonField.of("prompt")) - - val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) - - val GROUP = RestrictObjectType(JsonField.of("group")) - - val ROLE = RestrictObjectType(JsonField.of("role")) - - val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) - - val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) - - val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) - - fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - - @JsonDeserialize(builder = RemoveMemberPermission.Builder::class) - @NoAutoDetect - class RemoveMemberPermission - private constructor( - private val permission: JsonField, - private val restrictObjectType: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - fun permission(): Permission? = permission.getNullable("permission") - - /** The object type that the ACL applies to */ - fun restrictObjectType(): RestrictObjectType? = - restrictObjectType.getNullable("restrict_object_type") - - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles - */ - @JsonProperty("permission") @ExcludeMissing fun _permission() = permission - - /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - @ExcludeMissing - fun _restrictObjectType() = restrictObjectType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): RemoveMemberPermission = apply { - if (!validated) { - permission() - restrictObjectType() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveMemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var permission: JsonField = JsonMissing.of() - private var restrictObjectType: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(removeMemberPermission: RemoveMemberPermission) = apply { - this.permission = removeMemberPermission.permission - this.restrictObjectType = removeMemberPermission.restrictObjectType - additionalProperties(removeMemberPermission.additionalProperties) - } - - /** - * Each permission permits a certain type of operation on an object in the system - * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles - */ - fun permission(permission: 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 - */ - @JsonProperty("permission") - @ExcludeMissing - fun permission(permission: JsonField) = apply { - this.permission = permission - } - - /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType) = - restrictObjectType(JsonField.of(restrictObjectType)) - - /** The object type that the ACL applies to */ - @JsonProperty("restrict_object_type") - @ExcludeMissing - fun restrictObjectType(restrictObjectType: JsonField) = apply { - this.restrictObjectType = restrictObjectType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): RemoveMemberPermission = - RemoveMemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) - } - - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Permission && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val CREATE = Permission(JsonField.of("create")) - - val READ = Permission(JsonField.of("read")) - - val UPDATE = Permission(JsonField.of("update")) - - val DELETE = Permission(JsonField.of("delete")) - - val CREATE_ACLS = Permission(JsonField.of("create_acls")) - - val READ_ACLS = Permission(JsonField.of("read_acls")) - - val UPDATE_ACLS = Permission(JsonField.of("update_acls")) - - val DELETE_ACLS = Permission(JsonField.of("delete_acls")) - - fun of(value: String) = Permission(JsonField.of(value)) - } - - enum class Known { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - } - - enum class Value { - CREATE, - READ, - UPDATE, - DELETE, - CREATE_ACLS, - READ_ACLS, - UPDATE_ACLS, - DELETE_ACLS, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RestrictObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val ORGANIZATION = RestrictObjectType(JsonField.of("organization")) - - val PROJECT = RestrictObjectType(JsonField.of("project")) - - val EXPERIMENT = RestrictObjectType(JsonField.of("experiment")) - - val DATASET = RestrictObjectType(JsonField.of("dataset")) - - val PROMPT = RestrictObjectType(JsonField.of("prompt")) - - val PROMPT_SESSION = RestrictObjectType(JsonField.of("prompt_session")) - - val GROUP = RestrictObjectType(JsonField.of("group")) - - val ROLE = RestrictObjectType(JsonField.of("role")) - - val ORG_MEMBER = RestrictObjectType(JsonField.of("org_member")) - - val PROJECT_LOG = RestrictObjectType(JsonField.of("project_log")) - - val ORG_PROJECT = RestrictObjectType(JsonField.of("org_project")) - - fun of(value: String) = RestrictObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchView.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchView.kt deleted file mode 100755 index 2a496eb0..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PatchView.kt +++ /dev/null @@ -1,448 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = PatchView.Builder::class) -@NoAutoDetect -class PatchView -private constructor( - private val objectType: JsonField, - private val objectId: JsonField, - private val viewType: JsonField, - private val name: JsonField, - private val viewData: JsonField, - private val options: JsonField, - private val userId: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The object type that the ACL applies to */ - fun objectType(): ObjectType? = objectType.getNullable("object_type") - - /** The id of the object the view applies to */ - fun objectId(): String = objectId.getRequired("object_id") - - /** Type of table that the view corresponds to. */ - fun viewType(): ViewType? = viewType.getNullable("view_type") - - /** Name of the view */ - fun name(): String? = name.getNullable("name") - - /** The view definition */ - fun viewData(): ViewData? = viewData.getNullable("view_data") - - /** Options for the view in the app */ - fun options(): ViewOptions? = options.getNullable("options") - - /** Identifies the user who created the view */ - fun userId(): String? = userId.getNullable("user_id") - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType - - /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId - - /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType() = viewType - - /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData() = viewData - - /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options() = options - - /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): PatchView = apply { - if (!validated) { - objectType() - objectId() - viewType() - name() - viewData()?.validate() - options()?.validate() - userId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PatchView && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.viewType == other.viewType && - this.name == other.name && - this.viewData == other.viewData && - this.options == other.options && - this.userId == other.userId && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectType, - objectId, - viewType, - name, - viewData, - options, - userId, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "PatchView{objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, viewData=$viewData, options=$options, userId=$userId, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var objectType: JsonField = JsonMissing.of() - private var objectId: JsonField = JsonMissing.of() - private var viewType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var viewData: JsonField = JsonMissing.of() - private var options: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(patchView: PatchView) = apply { - this.objectType = patchView.objectType - this.objectId = patchView.objectId - this.viewType = patchView.viewType - this.name = patchView.name - this.viewData = patchView.viewData - this.options = patchView.options - this.userId = patchView.userId - additionalProperties(patchView.additionalProperties) - } - - /** The object type that the ACL applies to */ - fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) - - /** The object type that the ACL applies to */ - @JsonProperty("object_type") - @ExcludeMissing - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } - - /** The id of the object the view applies to */ - fun objectId(objectId: String) = objectId(JsonField.of(objectId)) - - /** The id of the object the view applies to */ - @JsonProperty("object_id") - @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } - - /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = viewType(JsonField.of(viewType)) - - /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") - @ExcludeMissing - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } - - /** Name of the view */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the view */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The view definition */ - fun viewData(viewData: ViewData) = viewData(JsonField.of(viewData)) - - /** The view definition */ - @JsonProperty("view_data") - @ExcludeMissing - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } - - /** Options for the view in the app */ - fun options(options: ViewOptions) = options(JsonField.of(options)) - - /** Options for the view in the app */ - @JsonProperty("options") - @ExcludeMissing - fun options(options: JsonField) = apply { this.options = options } - - /** Identifies the user who created the view */ - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** Identifies the user who created the view */ - @JsonProperty("user_id") - @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): PatchView = - PatchView( - objectType, - objectId, - viewType, - name, - viewData, - options, - userId, - additionalProperties.toUnmodifiable(), - ) - } - - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ObjectType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val ORGANIZATION = ObjectType(JsonField.of("organization")) - - val PROJECT = ObjectType(JsonField.of("project")) - - val EXPERIMENT = ObjectType(JsonField.of("experiment")) - - val DATASET = ObjectType(JsonField.of("dataset")) - - val PROMPT = ObjectType(JsonField.of("prompt")) - - val PROMPT_SESSION = ObjectType(JsonField.of("prompt_session")) - - val GROUP = ObjectType(JsonField.of("group")) - - val ROLE = ObjectType(JsonField.of("role")) - - val ORG_MEMBER = ObjectType(JsonField.of("org_member")) - - val PROJECT_LOG = ObjectType(JsonField.of("project_log")) - - val ORG_PROJECT = ObjectType(JsonField.of("org_project")) - - fun of(value: String) = ObjectType(JsonField.of(value)) - } - - enum class Known { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - } - - enum class Value { - ORGANIZATION, - PROJECT, - EXPERIMENT, - DATASET, - PROMPT, - PROMPT_SESSION, - GROUP, - ROLE, - ORG_MEMBER, - PROJECT_LOG, - ORG_PROJECT, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val PROJECTS = ViewType(JsonField.of("projects")) - - val LOGS = ViewType(JsonField.of("logs")) - - val EXPERIMENTS = ViewType(JsonField.of("experiments")) - - val DATASETS = ViewType(JsonField.of("datasets")) - - val PROMPTS = ViewType(JsonField.of("prompts")) - - val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) - - val EXPERIMENT = ViewType(JsonField.of("experiment")) - - val DATASET = ViewType(JsonField.of("dataset")) - - fun of(value: String) = ViewType(JsonField.of(value)) - } - - enum class Known { - PROJECTS, - LOGS, - EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, - EXPERIMENT, - DATASET, - } - - enum class Value { - PROJECTS, - LOGS, - EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, - EXPERIMENT, - DATASET, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt index 80699a99..752204e5 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PathLookupFilter.kt @@ -2,34 +2,51 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** - * A path-lookup filter describes an equality comparison against a specific sub-field in the event - * row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": - * "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"` + * A path-lookup filter describes an equality comparison against a specific + * sub-field in the event row. For instance, if you wish to filter on the value of + * `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `path=["input", "a", "b", "c"]` and `value="hello"` */ @JsonDeserialize(builder = PathLookupFilter.Builder::class) @NoAutoDetect -class PathLookupFilter -private constructor( - private val type: JsonField, - private val path: JsonField>, - private val value: JsonValue, - private val additionalProperties: Map, +class PathLookupFilter private constructor( + private val type: JsonField, + private val path: JsonField>, + private val value: JsonValue, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -40,37 +57,45 @@ private constructor( fun type(): Type = type.getRequired("type") /** - * List of fields describing the path to the value to be checked against. For instance, if you - * wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` + * List of fields describing the path to the value to be checked against. For + * instance, if you wish to filter on the value of `c` in + * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` */ fun path(): List = path.getRequired("path") /** - * The value to compare equality-wise against the event value at the specified `path`. The value - * must be a "primitive", that is, any JSON-serializable object except for objects and arrays. - * For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": - * {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` + * The value to compare equality-wise against the event value at the specified + * `path`. The value must be a "primitive", that is, any JSON-serializable object + * except for objects and arrays. For instance, if you wish to filter on the value + * of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `value="hello"` */ fun value(): JsonValue = value /** Denotes the type of filter as a path-lookup filter */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type /** - * List of fields describing the path to the value to be checked against. For instance, if you - * wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` + * List of fields describing the path to the value to be checked against. For + * instance, if you wish to filter on the value of `c` in + * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` */ - @JsonProperty("path") @ExcludeMissing fun _path() = path + @JsonProperty("path") + @ExcludeMissing + fun _path() = path /** - * The value to compare equality-wise against the event value at the specified `path`. The value - * must be a "primitive", that is, any JSON-serializable object except for objects and arrays. - * For instance, if you wish to filter on the value of "input.a.b.c" in the object `{"input": - * {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` + * The value to compare equality-wise against the event value at the specified + * `path`. The value must be a "primitive", that is, any JSON-serializable object + * except for objects and arrays. For instance, if you wish to filter on the value + * of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `value="hello"` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") + @ExcludeMissing + fun _value() = value @JsonAnyGetter @ExcludeMissing @@ -78,42 +103,40 @@ private constructor( fun validate(): PathLookupFilter = apply { if (!validated) { - type() - path() - value() - validated = true + type() + path() + value() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PathLookupFilter && - this.type == other.type && - this.path == other.path && - this.value == other.value && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PathLookupFilter && + this.type == other.type && + this.path == other.path && + this.value == other.value && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - path, - value, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + path, + value, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "PathLookupFilter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "PathLookupFilter{type=$type, path=$path, value=$value, additionalProperties=$additionalProperties}" companion object { @@ -140,33 +163,40 @@ private constructor( /** Denotes the type of filter as a path-lookup filter */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } /** - * List of fields describing the path to the value to be checked against. For instance, if - * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` + * List of fields describing the path to the value to be checked against. For + * instance, if you wish to filter on the value of `c` in + * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` */ fun path(path: List) = path(JsonField.of(path)) /** - * List of fields describing the path to the value to be checked against. For instance, if - * you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass - * `path=["input", "a", "b", "c"]` + * List of fields describing the path to the value to be checked against. For + * instance, if you wish to filter on the value of `c` in + * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` */ @JsonProperty("path") @ExcludeMissing - fun path(path: JsonField>) = apply { this.path = path } + fun path(path: JsonField>) = apply { + this.path = path + } /** - * The value to compare equality-wise against the event value at the specified `path`. The - * value must be a "primitive", that is, any JSON-serializable object except for objects and - * arrays. For instance, if you wish to filter on the value of "input.a.b.c" in the object - * `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `value="hello"` + * The value to compare equality-wise against the event value at the specified + * `path`. The value must be a "primitive", that is, any JSON-serializable object + * except for objects and arrays. For instance, if you wish to filter on the value + * of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass + * `value="hello"` */ @JsonProperty("value") @ExcludeMissing - fun value(value: JsonValue) = apply { this.value = value } + fun value(value: JsonValue) = apply { + this.value = value + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -182,29 +212,26 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PathLookupFilter = - PathLookupFilter( - type, - path.map { it.toUnmodifiable() }, - value, - additionalProperties.toUnmodifiable(), - ) + fun build(): PathLookupFilter = PathLookupFilter( + type, + path.map { it.toUnmodifiable() }, + value, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -227,17 +254,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - PATH_LOOKUP -> Value.PATH_LOOKUP - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PATH_LOOKUP -> Known.PATH_LOOKUP - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = when (this) { + PATH_LOOKUP -> Value.PATH_LOOKUP + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + PATH_LOOKUP -> Known.PATH_LOOKUP + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt index 238880d8..aef69965 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Project.kt @@ -2,31 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Project.Builder::class) @NoAutoDetect -class Project -private constructor( - private val id: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val created: JsonField, - private val deletedAt: JsonField, - private val userId: JsonField, - private val settings: JsonField, - private val additionalProperties: Map, +class Project private constructor( + private val id: JsonField, + private val orgId: JsonField, + private val name: JsonField, + private val created: JsonField, + private val deletedAt: JsonField, + private val userId: JsonField, + private val settings: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -54,24 +72,38 @@ private constructor( fun settings(): Settings? = settings.getNullable("settings") /** Unique identifier for the project */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId() = orgId /** Name of the project */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Date of project creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Date of project deletion, or null if the project is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt() = deletedAt /** Identifies the user who created the project */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId - @JsonProperty("settings") @ExcludeMissing fun _settings() = settings + @JsonProperty("settings") + @ExcludeMissing + fun _settings() = settings @JsonAnyGetter @ExcludeMissing @@ -79,54 +111,52 @@ private constructor( fun validate(): Project = apply { if (!validated) { - id() - orgId() - name() - created() - deletedAt() - userId() - settings()?.validate() - validated = true + id() + orgId() + name() + created() + deletedAt() + userId() + settings()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Project && - this.id == other.id && - this.orgId == other.orgId && - this.name == other.name && - this.created == other.created && - this.deletedAt == other.deletedAt && - this.userId == other.userId && - this.settings == other.settings && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Project && + this.id == other.id && + this.orgId == other.orgId && + this.name == other.name && + this.created == other.created && + this.deletedAt == other.deletedAt && + this.userId == other.userId && + this.settings == other.settings && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - orgId, - name, - created, - deletedAt, - userId, - settings, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + orgId, + name, + created, + deletedAt, + userId, + settings, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Project{id=$id, orgId=$orgId, name=$name, created=$created, deletedAt=$deletedAt, userId=$userId, settings=$settings, additionalProperties=$additionalProperties}" + override fun toString() = "Project{id=$id, orgId=$orgId, name=$name, created=$created, deletedAt=$deletedAt, userId=$userId, settings=$settings, additionalProperties=$additionalProperties}" companion object { @@ -159,7 +189,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -167,7 +201,9 @@ private constructor( /** Unique id for the organization that the project belongs under */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = apply { + this.orgId = orgId + } /** Name of the project */ fun name(name: String) = name(JsonField.of(name)) @@ -175,7 +211,9 @@ private constructor( /** Name of the project */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } /** Date of project creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -183,7 +221,9 @@ private constructor( /** Date of project creation */ @JsonProperty("created") @ExcludeMissing - 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.of(deletedAt)) @@ -191,7 +231,9 @@ private constructor( /** Date of project deletion, or null if the project is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } /** Identifies the user who created the project */ fun userId(userId: String) = userId(JsonField.of(userId)) @@ -199,13 +241,17 @@ private constructor( /** Identifies the user who created the project */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } fun settings(settings: Settings) = settings(JsonField.of(settings)) @JsonProperty("settings") @ExcludeMissing - fun settings(settings: JsonField) = apply { this.settings = settings } + fun settings(settings: JsonField) = apply { + this.settings = settings + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -221,26 +267,21 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Project = - Project( - id, - orgId, - name, - created, - deletedAt, - userId, - settings, - additionalProperties.toUnmodifiable(), - ) + fun build(): Project = Project( + id, + orgId, + name, + created, + deletedAt, + userId, + settings, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Settings.Builder::class) @NoAutoDetect - class Settings - private constructor( - private val comparisonKey: JsonField, - private val additionalProperties: Map, - ) { + class Settings private constructor(private val comparisonKey: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -250,7 +291,9 @@ private constructor( fun comparisonKey(): String? = comparisonKey.getNullable("comparison_key") /** The key used to join two experiments (defaults to `input`). */ - @JsonProperty("comparison_key") @ExcludeMissing fun _comparisonKey() = comparisonKey + @JsonProperty("comparison_key") + @ExcludeMissing + fun _comparisonKey() = comparisonKey @JsonAnyGetter @ExcludeMissing @@ -258,32 +301,31 @@ private constructor( fun validate(): Settings = apply { if (!validated) { - comparisonKey() - validated = true + comparisonKey() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Settings && - this.comparisonKey == other.comparisonKey && - this.additionalProperties == other.additionalProperties + return other is Settings && + this.comparisonKey == other.comparisonKey && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(comparisonKey, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(comparisonKey, additionalProperties) + } + return hashCode } - override fun toString() = - "Settings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" + override fun toString() = "Settings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" companion object { diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt index 80cddd02..1ff9bbeb 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectCreateParams.kt @@ -2,24 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectCreateParams constructor( + private val name: String, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectCreateParams -constructor( - private val name: String, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -27,11 +50,11 @@ constructor( fun orgName(): String? = orgName internal fun getBody(): ProjectCreateBody { - return ProjectCreateBody( - name, - orgName, - additionalBodyProperties, - ) + return ProjectCreateBody( + name, + orgName, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -40,24 +63,21 @@ constructor( @JsonDeserialize(builder = ProjectCreateBody.Builder::class) @NoAutoDetect - class ProjectCreateBody - internal constructor( - private val name: String?, - private val orgName: String?, - private val additionalProperties: Map, - ) { + class ProjectCreateBody internal constructor(private val name: String?, private val orgName: String?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the project */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = 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") fun orgName(): String? = orgName + @JsonProperty("org_name") + fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -66,30 +86,28 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectCreateBody && - this.name == other.name && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectCreateBody && + this.name == other.name && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectCreateBody{name=$name, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { @@ -109,15 +127,20 @@ constructor( } /** Name of the project */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = 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. */ @JsonProperty("org_name") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -133,12 +156,13 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectCreateBody = - ProjectCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectCreateBody = ProjectCreateBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -149,30 +173,29 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectCreateParams && - this.name == other.name && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectCreateParams && + this.name == other.name && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectCreateParams{name=$name, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -199,14 +222,18 @@ constructor( } /** Name of the project */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = 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) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -246,7 +273,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -257,18 +286,18 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectCreateParams = - ProjectCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectCreateParams = ProjectCreateParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt index ddf9a87e..793667b5 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ProjectDeleteParams -constructor( - private val projectId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectDeleteParams constructor( + private val projectId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun projectId(): String = projectId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectDeleteParams && - this.projectId == other.projectId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectDeleteParams && + this.projectId == other.projectId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectDeleteParams{projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectDeleteParams{projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectDeleteParams = - ProjectDeleteParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectDeleteParams = ProjectDeleteParams( + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt index d4351f63..f426cdd7 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPage.kt @@ -2,97 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Project import com.braintrustdata.api.services.blocking.ProjectService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class ProjectListPage -private constructor( - private val projectService: ProjectService, - private val params: ProjectListParams, - private val response: Response, -) { +class ProjectListPage private constructor(private val projectService: ProjectService, private val params: ProjectListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectListPage && - this.projectService == other.projectService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectListPage && + this.projectService == other.projectService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectService, - params, - response, - ) + return Objects.hash( + projectService, + params, + response, + ) } - override fun toString() = - "ProjectListPage{projectService=$projectService, params=$params, response=$response}" + override fun toString() = "ProjectListPage{projectService=$projectService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ProjectListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): ProjectListPage? { - return getNextPageParams()?.let { projectService.list(it) } + return getNextPageParams()?.let { + projectService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(projectService: ProjectService, params: ProjectListParams, response: Response) = - ProjectListPage( - projectService, - params, - response, - ) + fun of(projectService: ProjectService, params: ProjectListParams, response: Response) = ProjectListPage( + projectService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -100,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ProjectListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -153,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ProjectListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: ProjectListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt index 636c2d54..4a5dd4c7 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListPageAsync.kt @@ -2,99 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.ProjectServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Project +import com.braintrustdata.api.services.async.ProjectServiceAsync -class ProjectListPageAsync -private constructor( - private val projectService: ProjectServiceAsync, - private val params: ProjectListParams, - private val response: Response, -) { +class ProjectListPageAsync private constructor(private val projectService: ProjectServiceAsync, private val params: ProjectListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectListPageAsync && - this.projectService == other.projectService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectListPageAsync && + this.projectService == other.projectService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectService, - params, - response, - ) + return Objects.hash( + projectService, + params, + response, + ) } - override fun toString() = - "ProjectListPageAsync{projectService=$projectService, params=$params, response=$response}" + override fun toString() = "ProjectListPageAsync{projectService=$projectService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ProjectListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ProjectListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ProjectListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): ProjectListPageAsync? { - return getNextPageParams()?.let { projectService.list(it) } + return getNextPageParams()?.let { + projectService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(projectService: ProjectServiceAsync, params: ProjectListParams, response: Response) = - ProjectListPageAsync( - projectService, - params, - response, - ) + fun of(projectService: ProjectServiceAsync, params: ProjectListParams, response: Response) = ProjectListPageAsync( + projectService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -102,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ProjectListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -155,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ProjectListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: ProjectListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt index aeb9012f..9fa4eead 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectListParams.kt @@ -2,33 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectListParams constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class ProjectListParams -constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun endingBefore(): String? = endingBefore @@ -44,15 +61,27 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.projectName?.let { + params.put("project_name", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -62,36 +91,35 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectName == other.projectName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ProjectListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectName == other.projectName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ProjectListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectName=$projectName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -126,47 +154,63 @@ 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Name of the project to search for */ - fun projectName(projectName: String) = apply { this.projectName = projectName } + fun projectName(projectName: String) = apply { + this.projectName = projectName + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -206,82 +250,77 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): ProjectListParams = - ProjectListParams( - endingBefore, - ids, - limit, - orgName, - projectName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): ProjectListParams = ProjectListParams( + endingBefore, + ids, + limit, + orgName, + projectName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -298,38 +337,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt index 6410fe8c..516344fc 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParams.kt @@ -2,24 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectLogFeedbackParams constructor( + private val projectId: String, + private val feedback: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectLogFeedbackParams -constructor( - private val projectId: String, - private val feedback: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -27,7 +50,7 @@ constructor( fun feedback(): List = feedback internal fun getBody(): ProjectLogFeedbackBody { - return ProjectLogFeedbackBody(feedback, additionalBodyProperties) + return ProjectLogFeedbackBody(feedback, additionalBodyProperties) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -35,24 +58,21 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @JsonDeserialize(builder = ProjectLogFeedbackBody.Builder::class) @NoAutoDetect - class ProjectLogFeedbackBody - internal constructor( - private val feedback: List?, - private val additionalProperties: Map, - ) { + class ProjectLogFeedbackBody internal constructor(private val feedback: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of project logs feedback items */ - @JsonProperty("feedback") fun feedback(): List? = feedback + @JsonProperty("feedback") + fun feedback(): List? = feedback @JsonAnyGetter @ExcludeMissing @@ -61,24 +81,23 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectLogFeedbackBody && - this.feedback == other.feedback && - this.additionalProperties == other.additionalProperties + return other is ProjectLogFeedbackBody && + this.feedback == other.feedback && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(feedback, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(feedback, additionalProperties) + } + return hashCode } - override fun toString() = - "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectLogFeedbackBody{feedback=$feedback, additionalProperties=$additionalProperties}" companion object { @@ -115,12 +134,9 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogFeedbackBody = - ProjectLogFeedbackBody( - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() - ) + fun build(): ProjectLogFeedbackBody = ProjectLogFeedbackBody(checkNotNull(feedback) { + "`feedback` is required but was not set" + }.toUnmodifiable(), additionalProperties.toUnmodifiable()) } } @@ -131,30 +147,29 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFeedbackParams && - this.projectId == other.projectId && - this.feedback == other.feedback && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectLogFeedbackParams && + this.projectId == other.projectId && + this.feedback == other.feedback && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - feedback, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + feedback, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectLogFeedbackParams{projectId=$projectId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectLogFeedbackParams{projectId=$projectId, feedback=$feedback, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -181,7 +196,9 @@ constructor( } /** 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 { @@ -190,7 +207,9 @@ constructor( } /** A list of project logs feedback items */ - fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { this.feedback.add(feedback) } + fun addFeedback(feedback: FeedbackProjectLogsItem) = apply { + this.feedback.add(feedback) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -230,7 +249,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -241,19 +262,20 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectLogFeedbackParams = - ProjectLogFeedbackParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(feedback) { "`feedback` is required but was not set" } - .toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectLogFeedbackParams = ProjectLogFeedbackParams( + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + checkNotNull(feedback) { + "`feedback` is required but was not set" + }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt index 76681e1c..22fe8909 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchParams.kt @@ -2,20 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ProjectLogFetchParams -constructor( - private val projectId: String, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, +class ProjectLogFetchParams constructor( + private val projectId: String, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + ) { fun projectId(): String = projectId @@ -29,22 +58,30 @@ constructor( fun version(): String? = version internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.maxRootSpanId?.let { params.put("max_root_span_id", listOf(it.toString())) } - this.maxXactId?.let { params.put("max_xact_id", listOf(it.toString())) } - this.version?.let { params.put("version", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.maxRootSpanId?.let { + params.put("max_root_span_id", listOf(it.toString())) + } + this.maxXactId?.let { + params.put("max_xact_id", listOf(it.toString())) + } + this.version?.let { + params.put("version", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -52,34 +89,33 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchParams && - this.projectId == other.projectId && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ProjectLogFetchParams && + this.projectId == other.projectId && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - projectId, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + projectId, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ProjectLogFetchParams{projectId=$projectId, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -110,60 +146,72 @@ constructor( } /** 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 + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the 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 maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String) = 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) = apply { this.version = version } + fun version(version: String) = apply { + this.version = version + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -203,17 +251,20 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): ProjectLogFetchParams = - ProjectLogFetchParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): ProjectLogFetchParams = ProjectLogFetchParams( + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt index 16c32c43..b9f711ce 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParams.kt @@ -2,29 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectLogFetchPostParams constructor( + private val projectId: String, + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectLogFetchPostParams -constructor( - private val projectId: String, - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -42,15 +65,15 @@ constructor( fun version(): String? = version internal fun getBody(): ProjectLogFetchPostBody { - return ProjectLogFetchPostBody( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalBodyProperties, - ) + return ProjectLogFetchPostBody( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -58,98 +81,106 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @JsonDeserialize(builder = ProjectLogFetchPostBody.Builder::class) @NoAutoDetect - class ProjectLogFetchPostBody - internal constructor( - private val cursor: String?, - private val filters: List?, - private val limit: Long?, - private val maxRootSpanId: String?, - private val maxXactId: String?, - private val version: String?, - private val additionalProperties: Map, + class ProjectLogFetchPostBody internal constructor( + private val cursor: String?, + private val filters: List?, + private val limit: Long?, + private val maxRootSpanId: String?, + private val maxXactId: String?, + private val version: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** - * An opaque string to be used as a cursor for the next page of results, in order from - * latest to earliest. + * 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") fun cursor(): String? = cursor + @JsonProperty("cursor") + fun cursor(): String? = cursor /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ - @JsonProperty("filters") fun filters(): List? = filters + @JsonProperty("filters") + fun filters(): List? = filters /** * 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. */ - @JsonProperty("limit") fun limit(): Long? = limit + @JsonProperty("limit") + fun limit(): Long? = 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") fun maxRootSpanId(): String? = maxRootSpanId + @JsonProperty("max_root_span_id") + fun maxRootSpanId(): String? = 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") fun maxXactId(): String? = maxXactId + @JsonProperty("max_xact_id") + fun maxXactId(): String? = 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") fun version(): String? = version + @JsonProperty("version") + fun version(): String? = version @JsonAnyGetter @ExcludeMissing @@ -158,38 +189,36 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchPostBody && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectLogFetchPostBody && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectLogFetchPostBody{cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalProperties=$additionalProperties}" companion object { @@ -217,80 +246,96 @@ constructor( } /** - * 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") fun cursor(cursor: String) = apply { this.cursor = cursor } + @JsonProperty("cursor") + fun cursor(cursor: String) = apply { + this.cursor = cursor + } /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters - * are supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ @JsonProperty("filters") - fun filters(filters: List) = apply { this.filters = filters } + fun filters(filters: List) = apply { + this.filters = filters + } /** * 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. */ - @JsonProperty("limit") fun limit(limit: Long) = apply { this.limit = limit } + @JsonProperty("limit") + fun limit(limit: Long) = 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. */ @JsonProperty("max_root_span_id") - 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. */ @JsonProperty("max_xact_id") - fun maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String) = 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. */ - @JsonProperty("version") fun version(version: String) = apply { this.version = version } + @JsonProperty("version") + fun version(version: String) = apply { + this.version = version + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -306,16 +351,15 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogFetchPostBody = - ProjectLogFetchPostBody( - cursor, - filters?.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectLogFetchPostBody = ProjectLogFetchPostBody( + cursor, + filters?.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalProperties.toUnmodifiable(), + ) } } @@ -326,40 +370,39 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchPostParams && - this.projectId == other.projectId && - this.cursor == other.cursor && - this.filters == other.filters && - this.limit == other.limit && - this.maxRootSpanId == other.maxRootSpanId && - this.maxXactId == other.maxXactId && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectLogFetchPostParams && + this.projectId == other.projectId && + this.cursor == other.cursor && + this.filters == other.filters && + this.limit == other.limit && + this.maxRootSpanId == other.maxRootSpanId && + this.maxXactId == other.maxXactId && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - cursor, - filters, - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + cursor, + filters, + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectLogFetchPostParams{projectId=$projectId, cursor=$cursor, filters=$filters, limit=$limit, maxRootSpanId=$maxRootSpanId, maxXactId=$maxXactId, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -396,24 +439,28 @@ constructor( } /** 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 { this.cursor = cursor } + fun cursor(cursor: String) = apply { + this.cursor = cursor + } /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ fun filters(filters: List) = apply { this.filters.clear() @@ -421,67 +468,79 @@ constructor( } /** - * NOTE: This parameter is deprecated and will be removed in a future revision. Consider - * using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more - * advanced filtering. + * NOTE: This parameter is deprecated and will be removed in a future revision. + * Consider using the `/btql` endpoint + * (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. * - * A list of filters on the events to fetch. Currently, only path-lookup type filters are - * supported. + * A list of filters on the events to fetch. Currently, only path-lookup type + * filters are supported. */ - fun addFilter(filter: PathLookupFilter) = apply { this.filters.add(filter) } + fun addFilter(filter: PathLookupFilter) = apply { + this.filters.add(filter) + } /** * 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 + } /** - * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of - * the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' - * argument going forwards. + * DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in + * favor of the explicit 'cursor' returned by object fetch requests. Please prefer + * the 'cursor' argument going forwards. * * Together, `max_xact_id` and `max_root_span_id` form a pagination cursor * - * Since a paginated fetch query returns results in order from latest to earliest, the - * cursor for the next page can be found as the row with the minimum (earliest) value of the - * tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of - * paginating fetch queries. + * Since a paginated fetch query returns results in order from latest to earliest, + * the cursor for the next page can be found as the row with the 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 maxXactId(maxXactId: String) = apply { this.maxXactId = maxXactId } + fun maxXactId(maxXactId: String) = 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) = apply { this.version = version } + fun version(version: String) = apply { + this.version = version + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -521,7 +580,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -532,23 +593,23 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectLogFetchPostParams = - ProjectLogFetchPostParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - cursor, - if (filters.size == 0) null else filters.toUnmodifiable(), - limit, - maxRootSpanId, - maxXactId, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectLogFetchPostParams = ProjectLogFetchPostParams( + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + cursor, + if(filters.size == 0) null else filters.toUnmodifiable(), + limit, + maxRootSpanId, + maxXactId, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponse.kt deleted file mode 100755 index d4b38848..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponse.kt +++ /dev/null @@ -1,1628 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects - -@JsonDeserialize(builder = ProjectLogFetchPostResponse.Builder::class) -@NoAutoDetect -class ProjectLogFetchPostResponse -private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of fetched events */ - fun events(): List = events.getRequired("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. - */ - fun cursor(): String? = cursor.getNullable("cursor") - - /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = 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. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectLogFetchPostResponse = apply { - if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchPostResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectLogFetchPostResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var events: JsonField> = JsonMissing.of() - private var cursor: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(projectLogFetchPostResponse: ProjectLogFetchPostResponse) = apply { - this.events = projectLogFetchPostResponse.events - this.cursor = projectLogFetchPostResponse.cursor - additionalProperties(projectLogFetchPostResponse.additionalProperties) - } - - /** A list of fetched events */ - fun events(events: List) = events(JsonField.of(events)) - - /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } - - /** - * Pagination cursor - * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. - */ - fun cursor(cursor: String) = cursor(JsonField.of(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. - */ - @JsonProperty("cursor") - @ExcludeMissing - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectLogFetchPostResponse = - ProjectLogFetchPostResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Event.Builder::class) - @NoAutoDetect - class Event - private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val orgId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you - */ - 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) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** The timestamp the project logs event was created */ - fun created(): OffsetDateTime = created.getRequired("created") - - /** Unique id for the organization that the project belongs under */ - fun orgId(): String = orgId.getRequired("org_id") - - /** Unique identifier for the project */ - fun projectId(): String = projectId.getRequired("project_id") - - /** A literal 'g' which identifies the log as a project log */ - fun logId(): LogId = logId.getRequired("log_id") - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. - */ - fun expected(): JsonValue = expected - - /** - * 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.getNullable("scores") - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** A list of tags to log */ - fun tags(): List? = tags.getNullable("tags") - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced - */ - fun metrics(): Metrics? = metrics.getNullable("metrics") - - /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event - */ - fun context(): Context? = context.getNullable("context") - - /** - * 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") - - /** - * 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(): List? = spanParents.getNullable("span_parents") - - /** The `span_id` of the root of the trace this project logs event belongs to */ - fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): SpanAttributes? = spanAttributes.getNullable("span_attributes") - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the project logs (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - - /** Unique identifier for the project */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** - * 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() = spanId - - /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans - */ - @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents - - /** The `span_id` of the root of the trace this project logs event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Event = apply { - if (!validated) { - id() - _xactId() - created() - orgId() - projectId() - logId() - input() - output() - expected() - scores()?.validate() - metadata()?.validate() - tags() - metrics()?.validate() - context()?.validate() - spanId() - spanParents() - rootSpanId() - spanAttributes()?.validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.orgId == other.orgId && - this.projectId == other.projectId && - this.logId == other.logId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Event{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var logId: JsonField = JsonMissing.of() - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() - private var spanParents: JsonField> = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(event: Event) = apply { - this.id = event.id - this._xactId = event._xactId - this.created = event.created - this.orgId = event.orgId - this.projectId = event.projectId - this.logId = event.logId - this.input = event.input - this.output = event.output - this.expected = event.expected - this.scores = event.scores - this.metadata = event.metadata - this.tags = event.tags - this.metrics = event.metrics - this.context = event.context - this.spanId = event.spanId - this.spanParents = event.spanParents - this.rootSpanId = event.rootSpanId - this.spanAttributes = event.spanAttributes - additionalProperties(event.additionalProperties) - } - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust - * will generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust - * will generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** - * The 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) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** The timestamp the project logs event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** Unique id for the organization that the project belongs under */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - - /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - - /** Unique identifier for the project */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** A literal 'g' which identifies the log as a project log */ - fun logId(logId: LogId) = logId(JsonField.of(logId)) - - /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") - @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question. - */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * while digging into analyses. However, we may later use these values to re-score - * outputs or fine-tune your models. - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare logs. - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare logs. - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the project logs event. Use "start" and "end" to track the time span over which the - * project logs event was produced - */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the project logs event. Use "start" and "end" to track the time span over which the - * project logs event was produced - */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - fun context(context: Context) = context(JsonField.of(context)) - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** - * 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 - */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } - - /** - * An array of the parent `span_ids` of this project logs event. This should be empty - * for the root span of a trace, and should most often contain just one parent element - * for subspans - */ - fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) - - /** - * An array of the parent `span_ids` of this project logs event. This should be empty - * for the root span of a trace, and should most often contain just one parent element - * for subspans - */ - @JsonProperty("span_parents") - @ExcludeMissing - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents - } - - /** The `span_id` of the root of the trace this project logs event belongs to */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - - /** The `span_id` of the root of the trace this project logs event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Event = - Event( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanId, - spanParents.map { it.toUnmodifiable() }, - rootSpanId, - spanAttributes, - additionalProperties.toUnmodifiable(), - ) - } - - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogId && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val G = LogId(JsonField.of("g")) - - fun of(value: String) = LogId(JsonField.of(value)) - } - - enum class Known { - G, - } - - enum class Value { - G, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - G -> Value.G - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - G -> Known.G - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event - */ - @JsonDeserialize(builder = Context.Builder::class) - @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The function in code which created the project logs event */ - fun callerFunctionname(): String? = - callerFunctionname.getNullable("caller_functionname") - - /** Name of the file in code where the project logs event was created */ - fun callerFilename(): String? = callerFilename.getNullable("caller_filename") - - /** Line of code where the project logs event was created */ - fun callerLineno(): Long? = callerLineno.getNullable("caller_lineno") - - /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename - - /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var callerFunctionname: JsonField = JsonMissing.of() - private var callerFilename: JsonField = JsonMissing.of() - private var callerLineno: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) - } - - /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) - - /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } - - /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } - - /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) - - /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced - */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event started - */ - fun start(): Double? = start.getNullable("start") - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished - */ - fun end(): Double? = end.getNullable("end") - - /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) - */ - fun promptTokens(): Long? = promptTokens.getNullable("prompt_tokens") - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - fun completionTokens(): Long? = completionTokens.getNullable("completion_tokens") - - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(): Long? = tokens.getNullable("tokens") - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished - */ - @JsonProperty("end") @ExcludeMissing fun _end() = end - - /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) - */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens - - /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var start: JsonField = JsonMissing.of() - private var end: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var tokens: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - additionalProperties(metrics.additionalProperties) - } - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event started - */ - fun start(start: Double) = start(JsonField.of(start)) - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event started - */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished - */ - fun end(end: Double) = end(JsonField.of(end)) - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished - */ - @JsonProperty("end") - @ExcludeMissing - fun end(end: JsonField) = apply { this.end = end } - - /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) - */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - - /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the span, for display purposes only */ - fun name(): String? = name.getNullable("name") - - /** Type of the span, for display purposes only */ - fun type(): Type? = type.getNullable("type") - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val LLM = Type(JsonField.of("llm")) - - val SCORE = Type(JsonField.of("score")) - - val FUNCTION = Type(JsonField.of("function")) - - val EVAL = Type(JsonField.of("eval")) - - val TASK = Type(JsonField.of("task")) - - val TOOL = Type(JsonField.of("tool")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponse.kt deleted file mode 100755 index 87283f9a..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponse.kt +++ /dev/null @@ -1,1628 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.time.OffsetDateTime -import java.util.Objects - -@JsonDeserialize(builder = ProjectLogFetchResponse.Builder::class) -@NoAutoDetect -class ProjectLogFetchResponse -private constructor( - private val events: JsonField>, - private val cursor: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** A list of fetched events */ - fun events(): List = events.getRequired("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. - */ - fun cursor(): String? = cursor.getNullable("cursor") - - /** A list of fetched events */ - @JsonProperty("events") @ExcludeMissing fun _events() = 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. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor() = cursor - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectLogFetchResponse = apply { - if (!validated) { - events().forEach { it.validate() } - cursor() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogFetchResponse && - this.events == other.events && - this.cursor == other.cursor && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - events, - cursor, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "ProjectLogFetchResponse{events=$events, cursor=$cursor, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var events: JsonField> = JsonMissing.of() - private var cursor: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(projectLogFetchResponse: ProjectLogFetchResponse) = apply { - this.events = projectLogFetchResponse.events - this.cursor = projectLogFetchResponse.cursor - additionalProperties(projectLogFetchResponse.additionalProperties) - } - - /** A list of fetched events */ - fun events(events: List) = events(JsonField.of(events)) - - /** A list of fetched events */ - @JsonProperty("events") - @ExcludeMissing - fun events(events: JsonField>) = apply { this.events = events } - - /** - * Pagination cursor - * - * Pass this string directly as the `cursor` param to your next fetch request to get the - * next page of results. Not provided if the returned result set is empty. - */ - fun cursor(cursor: String) = cursor(JsonField.of(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. - */ - @JsonProperty("cursor") - @ExcludeMissing - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectLogFetchResponse = - ProjectLogFetchResponse( - events.map { it.toUnmodifiable() }, - cursor, - additionalProperties.toUnmodifiable(), - ) - } - - @JsonDeserialize(builder = Event.Builder::class) - @NoAutoDetect - class Event - private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val orgId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you - */ - 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) - */ - fun _xactId(): String = _xactId.getRequired("_xact_id") - - /** The timestamp the project logs event was created */ - fun created(): OffsetDateTime = created.getRequired("created") - - /** Unique id for the organization that the project belongs under */ - fun orgId(): String = orgId.getRequired("org_id") - - /** Unique identifier for the project */ - fun projectId(): String = projectId.getRequired("project_id") - - /** A literal 'g' which identifies the log as a project log */ - fun logId(): LogId = logId.getRequired("log_id") - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). - */ - fun input(): JsonValue = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. - */ - fun output(): JsonValue = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. - */ - fun expected(): JsonValue = expected - - /** - * 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.getNullable("scores") - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - fun metadata(): Metadata? = metadata.getNullable("metadata") - - /** A list of tags to log */ - fun tags(): List? = tags.getNullable("tags") - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced - */ - fun metrics(): Metrics? = metrics.getNullable("metrics") - - /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event - */ - fun context(): Context? = context.getNullable("context") - - /** - * 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") - - /** - * 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(): List? = spanParents.getNullable("span_parents") - - /** The `span_id` of the root of the trace this project logs event belongs to */ - fun rootSpanId(): String = rootSpanId.getRequired("root_span_id") - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(): SpanAttributes? = spanAttributes.getNullable("span_attributes") - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you - */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** - * The transaction id of an event is unique to the network operation that processed the - * event insertion. Transaction ids are monotonically increasing over time and can be used - * to retrieve a versioned snapshot of the project logs (see the `version` parameter) - */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId - - /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created - - /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId - - /** Unique identifier for the project */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId - - /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). - */ - @JsonProperty("input") @ExcludeMissing fun _input() = input - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. - */ - @JsonProperty("output") @ExcludeMissing fun _output() = output - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. - */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. - */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced - */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics - - /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event - */ - @JsonProperty("context") @ExcludeMissing fun _context() = context - - /** - * 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() = spanId - - /** - * An array of the parent `span_ids` of this project logs event. This should be empty for - * the root span of a trace, and should most often contain just one parent element for - * subspans - */ - @JsonProperty("span_parents") @ExcludeMissing fun _spanParents() = spanParents - - /** The `span_id` of the root of the trace this project logs event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Event = apply { - if (!validated) { - id() - _xactId() - created() - orgId() - projectId() - logId() - input() - output() - expected() - scores()?.validate() - metadata()?.validate() - tags() - metrics()?.validate() - context()?.validate() - spanId() - spanParents() - rootSpanId() - spanAttributes()?.validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Event && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.orgId == other.orgId && - this.projectId == other.projectId && - this.logId == other.logId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Event{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var _xactId: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var orgId: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var logId: JsonField = JsonMissing.of() - private var input: JsonValue = JsonMissing.of() - private var output: JsonValue = JsonMissing.of() - private var expected: JsonValue = JsonMissing.of() - private var scores: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var tags: JsonField> = JsonMissing.of() - private var metrics: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var spanId: JsonField = JsonMissing.of() - private var spanParents: JsonField> = JsonMissing.of() - private var rootSpanId: JsonField = JsonMissing.of() - private var spanAttributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(event: Event) = apply { - this.id = event.id - this._xactId = event._xactId - this.created = event.created - this.orgId = event.orgId - this.projectId = event.projectId - this.logId = event.logId - this.input = event.input - this.output = event.output - this.expected = event.expected - this.scores = event.scores - this.metadata = event.metadata - this.tags = event.tags - this.metrics = event.metrics - this.context = event.context - this.spanId = event.spanId - this.spanParents = event.spanParents - this.rootSpanId = event.rootSpanId - this.spanAttributes = event.spanAttributes - additionalProperties(event.additionalProperties) - } - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust - * will generate one for you - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust - * will generate one for you - */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** - * The 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) - */ - @JsonProperty("_xact_id") - @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } - - /** The timestamp the project logs event was created */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** The timestamp the project logs event was created */ - @JsonProperty("created") - @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } - - /** Unique id for the organization that the project belongs under */ - fun orgId(orgId: String) = orgId(JsonField.of(orgId)) - - /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") - @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } - - /** Unique identifier for the project */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** Unique identifier for the project */ - @JsonProperty("project_id") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** A literal 'g' which identifies the log as a project log */ - fun logId(logId: LogId) = logId(JsonField.of(logId)) - - /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") - @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } - - /** - * The arguments that uniquely define a user input (an arbitrary, JSON serializable - * object). - */ - @JsonProperty("input") - @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } - - /** - * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or - * not. For example, in an app that generates SQL queries, the `output` should be the - * _result_ of the SQL query generated by the model, not the query itself, because there - * may be multiple valid queries that answer a single question. - */ - @JsonProperty("output") - @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } - - /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently - * does not compare `output` to `expected` for you, since there are so many different - * ways to do that correctly. Instead, these values are just used to help you navigate - * while digging into analyses. However, we may later use these values to re-score - * outputs or fine-tune your models. - */ - @JsonProperty("expected") - @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare logs. - */ - fun scores(scores: Scores) = scores(JsonField.of(scores)) - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to - * what you expect and diagnose failures. For example, a summarization app might have - * one score that tells you how accurate the summary is, and another that measures the - * word similarity between the generated and grouth truth summary. The word similarity - * score could help you determine whether the summarization was covering similar - * concepts or not. You can use these scores to help you sort, filter, and compare logs. - */ - @JsonProperty("scores") - @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * A dictionary with additional data about the test example, model outputs, or just - * about anything else that's relevant, that you can use to help find and analyze - * examples later. For example, you could log the `prompt`, example's `id`, or anything - * else that would be useful to slice/dice later. The values in `metadata` can be any - * JSON-serializable type, but its keys must be strings - */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - /** A list of tags to log */ - fun tags(tags: List) = tags(JsonField.of(tags)) - - /** A list of tags to log */ - @JsonProperty("tags") - @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the project logs event. Use "start" and "end" to track the time span over which the - * project logs event was produced - */ - fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) - - /** - * Metrics are numerical measurements tracking the execution of the code that produced - * the project logs event. Use "start" and "end" to track the time span over which the - * project logs event was produced - */ - @JsonProperty("metrics") - @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - fun context(context: Context) = context(JsonField.of(context)) - - /** - * Context is additional information about the code that produced the project logs - * event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` - * attributes to track the location in code which produced the project logs event - */ - @JsonProperty("context") - @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } - - /** - * 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 - */ - @JsonProperty("span_id") - @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } - - /** - * An array of the parent `span_ids` of this project logs event. This should be empty - * for the root span of a trace, and should most often contain just one parent element - * for subspans - */ - fun spanParents(spanParents: List) = spanParents(JsonField.of(spanParents)) - - /** - * An array of the parent `span_ids` of this project logs event. This should be empty - * for the root span of a trace, and should most often contain just one parent element - * for subspans - */ - @JsonProperty("span_parents") - @ExcludeMissing - fun spanParents(spanParents: JsonField>) = apply { - this.spanParents = spanParents - } - - /** The `span_id` of the root of the trace this project logs event belongs to */ - fun rootSpanId(rootSpanId: String) = rootSpanId(JsonField.of(rootSpanId)) - - /** The `span_id` of the root of the trace this project logs event belongs to */ - @JsonProperty("root_span_id") - @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") - @ExcludeMissing - fun spanAttributes(spanAttributes: JsonField) = apply { - this.spanAttributes = spanAttributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Event = - Event( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanId, - spanParents.map { it.toUnmodifiable() }, - rootSpanId, - spanAttributes, - additionalProperties.toUnmodifiable(), - ) - } - - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LogId && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val G = LogId(JsonField.of("g")) - - fun of(value: String) = LogId(JsonField.of(value)) - } - - enum class Known { - G, - } - - enum class Value { - G, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - G -> Value.G - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - G -> Known.G - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - - /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event - */ - @JsonDeserialize(builder = Context.Builder::class) - @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** The function in code which created the project logs event */ - fun callerFunctionname(): String? = - callerFunctionname.getNullable("caller_functionname") - - /** Name of the file in code where the project logs event was created */ - fun callerFilename(): String? = callerFilename.getNullable("caller_filename") - - /** Line of code where the project logs event was created */ - fun callerLineno(): Long? = callerLineno.getNullable("caller_lineno") - - /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun _callerFunctionname() = callerFunctionname - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename - - /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Context = apply { - if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var callerFunctionname: JsonField = JsonMissing.of() - private var callerFilename: JsonField = JsonMissing.of() - private var callerLineno: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(context: Context) = apply { - this.callerFunctionname = context.callerFunctionname - this.callerFilename = context.callerFilename - this.callerLineno = context.callerLineno - additionalProperties(context.additionalProperties) - } - - /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) - - /** The function in code which created the project logs event */ - @JsonProperty("caller_functionname") - @ExcludeMissing - fun callerFunctionname(callerFunctionname: JsonField) = apply { - this.callerFunctionname = callerFunctionname - } - - /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) - - /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") - @ExcludeMissing - fun callerFilename(callerFilename: JsonField) = apply { - this.callerFilename = callerFilename - } - - /** Line of code where the project logs event was created */ - fun callerLineno(callerLineno: Long) = callerLineno(JsonField.of(callerLineno)) - - /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") - @ExcludeMissing - fun callerLineno(callerLineno: JsonField) = apply { - this.callerLineno = callerLineno - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings - */ - @JsonDeserialize(builder = Metadata.Builder::class) - @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metadata = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metadata: Metadata) = apply { - additionalProperties(metadata.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metadata = Metadata(additionalProperties.toUnmodifiable()) - } - } - - /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced - */ - @JsonDeserialize(builder = Metrics.Builder::class) - @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event started - */ - fun start(): Double? = start.getNullable("start") - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished - */ - fun end(): Double? = end.getNullable("end") - - /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) - */ - fun promptTokens(): Long? = promptTokens.getNullable("prompt_tokens") - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - fun completionTokens(): Long? = completionTokens.getNullable("completion_tokens") - - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(): Long? = tokens.getNullable("tokens") - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event started - */ - @JsonProperty("start") @ExcludeMissing fun _start() = start - - /** - * A unix timestamp recording when the section of code which produced the project logs - * event finished - */ - @JsonProperty("end") @ExcludeMissing fun _end() = end - - /** - * The number of tokens in the prompt used to generate the project logs event (only set - * if this is an LLM span) - */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens - - /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun _completionTokens() = completionTokens - - /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Metrics = apply { - if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var start: JsonField = JsonMissing.of() - private var end: JsonField = JsonMissing.of() - private var promptTokens: JsonField = JsonMissing.of() - private var completionTokens: JsonField = JsonMissing.of() - private var tokens: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(metrics: Metrics) = apply { - this.start = metrics.start - this.end = metrics.end - this.promptTokens = metrics.promptTokens - this.completionTokens = metrics.completionTokens - this.tokens = metrics.tokens - additionalProperties(metrics.additionalProperties) - } - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event started - */ - fun start(start: Double) = start(JsonField.of(start)) - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event started - */ - @JsonProperty("start") - @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished - */ - fun end(end: Double) = end(JsonField.of(end)) - - /** - * A unix timestamp recording when the section of code which produced the project - * logs event finished - */ - @JsonProperty("end") - @ExcludeMissing - fun end(end: JsonField) = apply { this.end = end } - - /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) - */ - fun promptTokens(promptTokens: Long) = promptTokens(JsonField.of(promptTokens)) - - /** - * The number of tokens in the prompt used to generate the project logs event (only - * set if this is an LLM span) - */ - @JsonProperty("prompt_tokens") - @ExcludeMissing - fun promptTokens(promptTokens: JsonField) = apply { - this.promptTokens = promptTokens - } - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - fun completionTokens(completionTokens: Long) = - completionTokens(JsonField.of(completionTokens)) - - /** - * The number of tokens in the completion generated by the model (only set if this - * is an LLM span) - */ - @JsonProperty("completion_tokens") - @ExcludeMissing - fun completionTokens(completionTokens: JsonField) = apply { - this.completionTokens = completionTokens - } - - /** The total number of tokens in the input and output of the project logs event. */ - fun tokens(tokens: Long) = tokens(JsonField.of(tokens)) - - /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") - @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) - } - } - - /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. - */ - @JsonDeserialize(builder = Scores.Builder::class) - @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Scores = apply { - if (!validated) { - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scores && this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode - } - - override fun toString() = "Scores{additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(scores: Scores) = apply { - additionalProperties(scores.additionalProperties) - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Scores = Scores(additionalProperties.toUnmodifiable()) - } - } - - /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonDeserialize(builder = SpanAttributes.Builder::class) - @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Name of the span, for display purposes only */ - fun name(): String? = name.getNullable("name") - - /** Type of the span, for display purposes only */ - fun type(): Type? = type.getNullable("type") - - /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): SpanAttributes = apply { - if (!validated) { - name() - type() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(spanAttributes: SpanAttributes) = apply { - this.name = spanAttributes.name - this.type = spanAttributes.type - additionalProperties(spanAttributes.additionalProperties) - } - - /** Name of the span, for display purposes only */ - fun name(name: String) = name(JsonField.of(name)) - - /** Name of the span, for display purposes only */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** Type of the span, for display purposes only */ - fun type(type: Type) = type(JsonField.of(type)) - - /** Type of the span, for display purposes only */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val LLM = Type(JsonField.of("llm")) - - val SCORE = Type(JsonField.of("score")) - - val FUNCTION = Type(JsonField.of("function")) - - val EVAL = Type(JsonField.of("eval")) - - val TASK = Type(JsonField.of("task")) - - val TOOL = Type(JsonField.of("tool")) - - fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - } - - enum class Value { - LLM, - SCORE, - FUNCTION, - EVAL, - TASK, - TOOL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt index e68df8d4..eebd610a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertParams.kt @@ -2,34 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectLogInsertParams constructor( + private val projectId: String, + private val events: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectLogInsertParams -constructor( - private val projectId: String, - private val events: List, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -37,7 +50,7 @@ constructor( fun events(): List = events internal fun getBody(): ProjectLogInsertBody { - return ProjectLogInsertBody(events, additionalBodyProperties) + return ProjectLogInsertBody(events, additionalBodyProperties) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -45,24 +58,21 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @JsonDeserialize(builder = ProjectLogInsertBody.Builder::class) @NoAutoDetect - class ProjectLogInsertBody - internal constructor( - private val events: List?, - private val additionalProperties: Map, - ) { + class ProjectLogInsertBody internal constructor(private val events: List?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** A list of project logs events to insert */ - @JsonProperty("events") fun events(): List? = events + @JsonProperty("events") + fun events(): List? = events @JsonAnyGetter @ExcludeMissing @@ -71,24 +81,23 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectLogInsertBody && - this.events == other.events && - this.additionalProperties == other.additionalProperties + return other is ProjectLogInsertBody && + this.events == other.events && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(events, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(events, additionalProperties) + } + return hashCode } - override fun toString() = - "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectLogInsertBody{events=$events, additionalProperties=$additionalProperties}" companion object { @@ -106,7 +115,10 @@ constructor( } /** A list of project logs events to insert */ - @JsonProperty("events") fun events(events: List) = apply { this.events = events } + @JsonProperty("events") + fun events(events: List) = apply { + this.events = events + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -122,12 +134,9 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogInsertBody = - ProjectLogInsertBody( - checkNotNull(events) { "`events` is required but was not set" } - .toUnmodifiable(), - additionalProperties.toUnmodifiable() - ) + fun build(): ProjectLogInsertBody = ProjectLogInsertBody(checkNotNull(events) { + "`events` is required but was not set" + }.toUnmodifiable(), additionalProperties.toUnmodifiable()) } } @@ -138,30 +147,29 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogInsertParams && - this.projectId == other.projectId && - this.events == other.events && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectLogInsertParams && + this.projectId == other.projectId && + this.events == other.events && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - events, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + events, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectLogInsertParams{projectId=$projectId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectLogInsertParams{projectId=$projectId, events=$events, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -188,7 +196,9 @@ constructor( } /** 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 { @@ -197,7 +207,9 @@ constructor( } /** A list of project logs events to insert */ - fun addEvent(event: Event) = apply { this.events.add(event) } + fun addEvent(event: Event) = apply { + this.events.add(event) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -237,7 +249,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -248,158 +262,124 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectLogInsertParams = - ProjectLogInsertParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(events) { "`events` is required but was not set" }.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectLogInsertParams = ProjectLogInsertParams( + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + checkNotNull(events) { + "`events` is required but was not set" + }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Event.Deserializer::class) @JsonSerialize(using = Event.Serializer::class) - class Event - private constructor( - private val insertProjectLogsEventReplace: InsertProjectLogsEventReplace? = null, - private val insertProjectLogsEventMerge: InsertProjectLogsEventMerge? = null, - private val _json: JsonValue? = null, - ) { + class Event private constructor(private val insertProjectLogsEventReplace: InsertProjectLogsEventReplace? = null, private val insertProjectLogsEventMerge: InsertProjectLogsEventMerge? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false - fun insertProjectLogsEventReplace(): InsertProjectLogsEventReplace? = - insertProjectLogsEventReplace - - fun insertProjectLogsEventMerge(): InsertProjectLogsEventMerge? = - insertProjectLogsEventMerge + fun insertProjectLogsEventReplace(): InsertProjectLogsEventReplace? = insertProjectLogsEventReplace + fun insertProjectLogsEventMerge(): InsertProjectLogsEventMerge? = insertProjectLogsEventMerge fun isInsertProjectLogsEventReplace(): Boolean = insertProjectLogsEventReplace != null - fun isInsertProjectLogsEventMerge(): Boolean = insertProjectLogsEventMerge != null - fun asInsertProjectLogsEventReplace(): InsertProjectLogsEventReplace = - insertProjectLogsEventReplace.getOrThrow("insertProjectLogsEventReplace") - - fun asInsertProjectLogsEventMerge(): InsertProjectLogsEventMerge = - insertProjectLogsEventMerge.getOrThrow("insertProjectLogsEventMerge") + fun asInsertProjectLogsEventReplace(): InsertProjectLogsEventReplace = insertProjectLogsEventReplace.getOrThrow("insertProjectLogsEventReplace") + fun asInsertProjectLogsEventMerge(): InsertProjectLogsEventMerge = insertProjectLogsEventMerge.getOrThrow("insertProjectLogsEventMerge") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - insertProjectLogsEventReplace != null -> - visitor.visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace) - insertProjectLogsEventMerge != null -> - visitor.visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge) - else -> visitor.unknown(_json) - } + return when { + insertProjectLogsEventReplace != null -> visitor.visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace) + insertProjectLogsEventMerge != null -> visitor.visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge) + else -> visitor.unknown(_json) + } } fun validate(): Event = apply { if (!validated) { - if (insertProjectLogsEventReplace == null && insertProjectLogsEventMerge == null) { - throw BraintrustInvalidDataException("Unknown Event: $_json") - } - insertProjectLogsEventReplace?.validate() - insertProjectLogsEventMerge?.validate() - validated = true + if (insertProjectLogsEventReplace == null && insertProjectLogsEventMerge == null) { + throw BraintrustInvalidDataException("Unknown Event: $_json") + } + insertProjectLogsEventReplace?.validate() + insertProjectLogsEventMerge?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Event && - this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && - this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge + return other is Event && + this.insertProjectLogsEventReplace == other.insertProjectLogsEventReplace && + this.insertProjectLogsEventMerge == other.insertProjectLogsEventMerge } override fun hashCode(): Int { - return Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) + return Objects.hash(insertProjectLogsEventReplace, insertProjectLogsEventMerge) } override fun toString(): String { - return when { - insertProjectLogsEventReplace != null -> - "Event{insertProjectLogsEventReplace=$insertProjectLogsEventReplace}" - insertProjectLogsEventMerge != null -> - "Event{insertProjectLogsEventMerge=$insertProjectLogsEventMerge}" - _json != null -> "Event{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Event") - } + return when { + insertProjectLogsEventReplace != null -> "Event{insertProjectLogsEventReplace=$insertProjectLogsEventReplace}" + insertProjectLogsEventMerge != null -> "Event{insertProjectLogsEventMerge=$insertProjectLogsEventMerge}" + _json != null -> "Event{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Event") + } } companion object { - fun ofInsertProjectLogsEventReplace( - insertProjectLogsEventReplace: InsertProjectLogsEventReplace - ) = Event(insertProjectLogsEventReplace = insertProjectLogsEventReplace) + fun ofInsertProjectLogsEventReplace(insertProjectLogsEventReplace: InsertProjectLogsEventReplace) = Event(insertProjectLogsEventReplace = insertProjectLogsEventReplace) - fun ofInsertProjectLogsEventMerge( - insertProjectLogsEventMerge: InsertProjectLogsEventMerge - ) = Event(insertProjectLogsEventMerge = insertProjectLogsEventMerge) + fun ofInsertProjectLogsEventMerge(insertProjectLogsEventMerge: InsertProjectLogsEventMerge) = Event(insertProjectLogsEventMerge = insertProjectLogsEventMerge) } interface Visitor { - fun visitInsertProjectLogsEventReplace( - insertProjectLogsEventReplace: InsertProjectLogsEventReplace - ): T + fun visitInsertProjectLogsEventReplace(insertProjectLogsEventReplace: InsertProjectLogsEventReplace): T - fun visitInsertProjectLogsEventMerge( - insertProjectLogsEventMerge: InsertProjectLogsEventMerge - ): T + fun visitInsertProjectLogsEventMerge(insertProjectLogsEventMerge: InsertProjectLogsEventMerge): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Event: $json") + throw BraintrustInvalidDataException("Unknown Event: $json") } } class Deserializer : BaseDeserializer(Event::class) { override fun ObjectCodec.deserialize(node: JsonNode): Event { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertProjectLogsEventReplace = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Event(insertProjectLogsEventMerge = it, _json = json) - } - - return Event(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Event(insertProjectLogsEventReplace = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Event(insertProjectLogsEventMerge = it, _json = json) + } + + return Event(_json = json) } } class Serializer : BaseSerializer(Event::class) { - override fun serialize( - value: Event, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.insertProjectLogsEventReplace != null -> - generator.writeObject(value.insertProjectLogsEventReplace) - value.insertProjectLogsEventMerge != null -> - generator.writeObject(value.insertProjectLogsEventMerge) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Event") - } + override fun serialize(value: Event, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.insertProjectLogsEventReplace != null -> generator.writeObject(value.insertProjectLogsEventReplace) + value.insertProjectLogsEventMerge != null -> generator.writeObject(value.insertProjectLogsEventMerge) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Event") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt deleted file mode 100755 index 11b862a5..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponse.kt +++ /dev/null @@ -1,121 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects - -@JsonDeserialize(builder = ProjectLogInsertResponse.Builder::class) -@NoAutoDetect -class ProjectLogInsertResponse -private constructor( - private val rowIds: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as input - */ - 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 - */ - @JsonProperty("row_ids") @ExcludeMissing fun _rowIds() = rowIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectLogInsertResponse = apply { - if (!validated) { - rowIds() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogInsertResponse && - this.rowIds == other.rowIds && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(rowIds, additionalProperties) - } - return hashCode - } - - override fun toString() = - "ProjectLogInsertResponse{rowIds=$rowIds, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var rowIds: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(projectLogInsertResponse: ProjectLogInsertResponse) = apply { - this.rowIds = projectLogInsertResponse.rowIds - additionalProperties(projectLogInsertResponse.additionalProperties) - } - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - fun rowIds(rowIds: List) = rowIds(JsonField.of(rowIds)) - - /** - * The ids of all rows that were inserted, aligning one-to-one with the rows provided as - * input - */ - @JsonProperty("row_ids") - @ExcludeMissing - fun rowIds(rowIds: JsonField>) = apply { this.rowIds = rowIds } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectLogInsertResponse = - ProjectLogInsertResponse( - rowIds.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable() - ) - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt index 618dd3b3..00a45b80 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectLogsEvent.kt @@ -2,46 +2,61 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ProjectLogsEvent.Builder::class) @NoAutoDetect -class ProjectLogsEvent -private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val created: JsonField, - private val orgId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val input: JsonValue, - private val output: JsonValue, - private val expected: JsonValue, - private val error: JsonValue, - private val scores: JsonField, - private val metadata: JsonField, - private val tags: JsonField>, - private val metrics: JsonField, - private val context: JsonField, - private val spanId: JsonField, - private val spanParents: JsonField>, - private val rootSpanId: JsonField, - private val spanAttributes: JsonField, - private val additionalProperties: Map, +class ProjectLogsEvent private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val created: JsonField, + private val orgId: JsonField, + private val projectId: JsonField, + private val logId: JsonField, + private val input: JsonValue, + private val output: JsonValue, + private val expected: JsonValue, + private val error: JsonValue, + private val scores: JsonField, + private val metadata: JsonField, + private val tags: JsonField>, + private val metrics: JsonField, + private val context: JsonField, + private val spanId: JsonField, + private val spanParents: JsonField>, + private val rootSpanId: JsonField, + private val spanAttributes: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -49,15 +64,16 @@ private constructor( private var hashCode: Int = 0 /** - * A unique identifier for the project logs event. If you don't provide one, BrainTrust will - * generate one for you + * 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") @@ -73,25 +89,28 @@ private constructor( /** A literal 'g' which identifies the log as a project log */ fun logId(): LogId = logId.getRequired("log_id") - /** 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(): JsonValue = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ fun output(): JsonValue = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ fun expected(): JsonValue = expected @@ -99,22 +118,23 @@ private constructor( fun error(): JsonValue = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * 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.getNullable("scores") /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else 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.getNullable("metadata") @@ -122,29 +142,32 @@ private constructor( fun tags(): List? = tags.getNullable("tags") /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * 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.getNullable("metrics") /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * 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.getNullable("context") /** - * 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") /** - * 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(): List? = spanParents.getNullable("span_parents") @@ -155,110 +178,156 @@ private constructor( fun spanAttributes(): SpanAttributes? = spanAttributes.getNullable("span_attributes") /** - * 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() = id + @JsonProperty("id") + @ExcludeMissing + fun _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) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId() = _xactId /** The timestamp the project logs event was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Unique id for the organization that the project belongs under */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId() = orgId /** Unique identifier for the project */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId() = projectId /** A literal 'g' which identifies the log as a project log */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId + @JsonProperty("log_id") + @ExcludeMissing + fun _logId() = logId - /** The arguments that uniquely define a user input (an arbitrary, JSON serializable object). */ - @JsonProperty("input") @ExcludeMissing fun _input() = input + /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable + * object). + */ + @JsonProperty("input") + @ExcludeMissing + fun _input() = input /** - * The output of your application, including post-processing (an arbitrary, JSON serializable - * object), that allows you to determine whether the result is correct or not. For example, in - * an app that generates SQL queries, the `output` should be the _result_ of the SQL query - * generated by the model, not the query itself, because there may be multiple valid queries - * that answer a single question. + * The output of your application, including post-processing (an arbitrary, JSON + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ - @JsonProperty("output") @ExcludeMissing fun _output() = output + @JsonProperty("output") + @ExcludeMissing + fun _output() = output /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does not - * compare `output` to `expected` for you, since there are so many different ways to do that - * correctly. Instead, these values are just used to help you navigate while digging into - * analyses. However, we may later use these values to re-score outputs or fine-tune your - * models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ - @JsonProperty("expected") @ExcludeMissing fun _expected() = expected + @JsonProperty("expected") + @ExcludeMissing + fun _expected() = expected /** The error that occurred, if any. */ - @JsonProperty("error") @ExcludeMissing fun _error() = error + @JsonProperty("error") + @ExcludeMissing + fun _error() = error /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety - * of signals that help you determine how accurate the outputs are compared to what you expect - * and diagnose failures. For example, a summarization app might have one score that tells you - * how accurate the summary is, and another that measures the word similarity between the - * generated and grouth truth summary. The word similarity score could help you determine - * whether the summarization was covering similar concepts or not. You can use these scores to + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to * help you sort, filter, and compare logs. */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores() = scores /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else that would be useful to - * slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys - * must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata /** A list of tags to log */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project logs - * event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics() = metrics /** - * Context is additional information about the code that produced the project logs event. It is - * essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the - * location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ - @JsonProperty("context") @ExcludeMissing fun _context() = context + @JsonProperty("context") + @ExcludeMissing + fun _context() = context /** - * 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() = spanId + @JsonProperty("span_id") + @ExcludeMissing + fun _spanId() = spanId /** - * 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() = spanParents + @JsonProperty("span_parents") + @ExcludeMissing + fun _spanParents() = spanParents /** The `span_id` of the root of the trace this project logs event belongs to */ - @JsonProperty("root_span_id") @ExcludeMissing fun _rootSpanId() = rootSpanId + @JsonProperty("root_span_id") + @ExcludeMissing + fun _rootSpanId() = rootSpanId /** Human-identifying attributes of the span, such as name, type, etc. */ - @JsonProperty("span_attributes") @ExcludeMissing fun _spanAttributes() = spanAttributes + @JsonProperty("span_attributes") + @ExcludeMissing + fun _spanAttributes() = spanAttributes @JsonAnyGetter @ExcludeMissing @@ -266,90 +335,88 @@ private constructor( fun validate(): ProjectLogsEvent = apply { if (!validated) { - id() - _xactId() - created() - orgId() - projectId() - logId() - input() - output() - expected() - error() - scores()?.validate() - metadata()?.validate() - tags() - metrics()?.validate() - context()?.validate() - spanId() - spanParents() - rootSpanId() - spanAttributes()?.validate() - validated = true + id() + _xactId() + created() + orgId() + projectId() + logId() + input() + output() + expected() + error() + scores()?.validate() + metadata()?.validate() + tags() + metrics()?.validate() + context()?.validate() + spanId() + spanParents() + rootSpanId() + spanAttributes()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectLogsEvent && - this.id == other.id && - this._xactId == other._xactId && - this.created == other.created && - this.orgId == other.orgId && - this.projectId == other.projectId && - this.logId == other.logId && - this.input == other.input && - this.output == other.output && - this.expected == other.expected && - this.error == other.error && - this.scores == other.scores && - this.metadata == other.metadata && - this.tags == other.tags && - this.metrics == other.metrics && - this.context == other.context && - this.spanId == other.spanId && - this.spanParents == other.spanParents && - this.rootSpanId == other.rootSpanId && - this.spanAttributes == other.spanAttributes && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectLogsEvent && + this.id == other.id && + this._xactId == other._xactId && + this.created == other.created && + this.orgId == other.orgId && + this.projectId == other.projectId && + this.logId == other.logId && + this.input == other.input && + this.output == other.output && + this.expected == other.expected && + this.error == other.error && + this.scores == other.scores && + this.metadata == other.metadata && + this.tags == other.tags && + this.metrics == other.metrics && + this.context == other.context && + this.spanId == other.spanId && + this.spanParents == other.spanParents && + this.rootSpanId == other.rootSpanId && + this.spanAttributes == other.spanAttributes && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - error, - scores, - metadata, - tags, - metrics, - context, - spanId, - spanParents, - rootSpanId, - spanAttributes, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + _xactId, + created, + orgId, + projectId, + logId, + input, + output, + expected, + error, + scores, + metadata, + tags, + metrics, + context, + spanId, + spanParents, + rootSpanId, + spanAttributes, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectLogsEvent{id=$id, _xactId=$_xactId, created=$created, orgId=$orgId, projectId=$projectId, logId=$logId, input=$input, output=$output, expected=$expected, error=$error, scores=$scores, metadata=$metadata, tags=$tags, metrics=$metrics, context=$context, spanId=$spanId, spanParents=$spanParents, rootSpanId=$rootSpanId, spanAttributes=$spanAttributes, additionalProperties=$additionalProperties}" companion object { @@ -403,32 +470,40 @@ private constructor( } /** - * 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 */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + 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) */ @JsonProperty("_xact_id") @ExcludeMissing - 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)) @@ -436,7 +511,9 @@ private constructor( /** The timestamp the project logs event was created */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** Unique id for the organization that the project belongs under */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -444,7 +521,9 @@ private constructor( /** Unique id for the organization that the project belongs under */ @JsonProperty("org_id") @ExcludeMissing - 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)) @@ -452,7 +531,9 @@ private constructor( /** Unique identifier for the project */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } /** A literal 'g' which identifies the log as a project log */ fun logId(logId: LogId) = logId(JsonField.of(logId)) @@ -460,86 +541,103 @@ private constructor( /** A literal 'g' which identifies the log as a project log */ @JsonProperty("log_id") @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } + fun logId(logId: JsonField) = apply { + this.logId = logId + } /** - * 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). */ @JsonProperty("input") @ExcludeMissing - fun input(input: JsonValue) = apply { this.input = input } + fun input(input: JsonValue) = apply { + this.input = input + } /** * The output of your application, including post-processing (an arbitrary, JSON - * serializable object), that allows you to determine whether the result is correct or not. - * For example, in an app that generates SQL queries, the `output` should be the _result_ of - * the SQL query generated by the model, not the query itself, because there may be multiple - * valid queries that answer a single question. + * serializable object), that allows you to determine whether the result is correct + * or not. For example, in an app that generates SQL queries, the `output` should + * be the _result_ of the SQL query generated by the model, not the query itself, + * because there may be multiple valid queries that answer a single question. */ @JsonProperty("output") @ExcludeMissing - fun output(output: JsonValue) = apply { this.output = output } + fun output(output: JsonValue) = apply { + this.output = output + } /** - * The ground truth value (an arbitrary, JSON serializable object) that you'd compare to - * `output` to determine if your `output` value is correct or not. Braintrust currently does - * not compare `output` to `expected` for you, since there are so many different ways to do - * that correctly. Instead, these values are just used to help you navigate while digging - * into analyses. However, we may later use these values to re-score outputs or fine-tune - * your models. + * The ground truth value (an arbitrary, JSON serializable object) that you'd + * compare to `output` to determine if your `output` value is correct or not. + * Braintrust currently does not compare `output` to `expected` for you, since + * there are so many different ways to do that correctly. Instead, these values are + * just used to help you navigate while digging into analyses. However, we may + * later use these values to re-score outputs or fine-tune your models. */ @JsonProperty("expected") @ExcludeMissing - fun expected(expected: JsonValue) = apply { this.expected = expected } + fun expected(expected: JsonValue) = apply { + this.expected = expected + } /** The error that occurred, if any. */ @JsonProperty("error") @ExcludeMissing - fun error(error: JsonValue) = apply { this.error = error } + fun error(error: JsonValue) = apply { + this.error = error + } /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ fun scores(scores: Scores) = scores(JsonField.of(scores)) /** - * A dictionary of numeric values (between 0 and 1) to log. The scores should give you a - * variety of signals that help you determine how accurate the outputs are compared to what - * you expect and diagnose failures. For example, a summarization app might have one score - * that tells you how accurate the summary is, and another that measures the word similarity - * between the generated and grouth truth summary. The word similarity score could help you - * determine whether the summarization was covering similar concepts or not. You can use - * these scores to help you sort, filter, and compare logs. + * A dictionary of numeric values (between 0 and 1) to log. The scores should give + * you a variety of signals that help you determine how accurate the outputs are + * compared to what you expect and diagnose failures. For example, a summarization + * app might have one score that tells you how accurate the summary is, and another + * that measures the word similarity between the generated and grouth truth + * summary. The word similarity score could help you determine whether the + * summarization was covering similar concepts or not. You can use these scores to + * help you sort, filter, and compare logs. */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = apply { + this.scores = scores + } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. - * For example, you could log the `prompt`, example's `id`, or anything else that would be - * useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, - * but its keys must be strings + * A dictionary with additional data about the test example, model outputs, or just + * about anything else that's relevant, that you can use to help find and analyze + * examples later. For example, you could log the `prompt`, example's `id`, or + * anything else that would be useful to slice/dice later. The values in `metadata` + * can be any JSON-serializable type, but its keys must be strings */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } /** A list of tags to log */ fun tags(tags: List) = tags(JsonField.of(tags)) @@ -547,67 +645,79 @@ private constructor( /** A list of tags to log */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) /** - * Metrics are numerical measurements tracking the execution of the code that produced the - * project logs event. Use "start" and "end" to track the time span over which the project - * logs event was produced + * Metrics are numerical measurements tracking the execution of the code that + * produced the project logs event. Use "start" and "end" to track the time span + * over which the project logs event was produced */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = apply { + this.metrics = metrics + } /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ fun context(context: Context) = context(JsonField.of(context)) /** - * Context is additional information about the code that produced the project logs event. It - * is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to - * track the location in code which produced the project logs event + * Context is additional information about the code that produced the project logs + * event. It is essentially the textual counterpart to `metrics`. Use the + * `caller_*` attributes to track the location in code which produced the project + * logs event */ @JsonProperty("context") @ExcludeMissing - fun context(context: JsonField) = apply { this.context = context } + fun context(context: JsonField) = apply { + this.context = context + } /** - * 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 */ @JsonProperty("span_id") @ExcludeMissing - fun spanId(spanId: JsonField) = apply { this.spanId = spanId } + fun spanId(spanId: JsonField) = apply { + this.spanId = spanId + } /** - * 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.of(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 */ @JsonProperty("span_parents") @ExcludeMissing @@ -621,11 +731,12 @@ private constructor( /** The `span_id` of the root of the trace this project logs event belongs to */ @JsonProperty("root_span_id") @ExcludeMissing - fun rootSpanId(rootSpanId: JsonField) = apply { this.rootSpanId = rootSpanId } + fun rootSpanId(rootSpanId: JsonField) = apply { + this.rootSpanId = rootSpanId + } /** Human-identifying attributes of the span, such as name, type, etc. */ - fun spanAttributes(spanAttributes: SpanAttributes) = - spanAttributes(JsonField.of(spanAttributes)) + fun spanAttributes(spanAttributes: SpanAttributes) = spanAttributes(JsonField.of(spanAttributes)) /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonProperty("span_attributes") @@ -648,45 +759,42 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectLogsEvent = - ProjectLogsEvent( - id, - _xactId, - created, - orgId, - projectId, - logId, - input, - output, - expected, - error, - scores, - metadata, - tags.map { it.toUnmodifiable() }, - metrics, - context, - spanId, - spanParents.map { it.toUnmodifiable() }, - rootSpanId, - spanAttributes, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectLogsEvent = ProjectLogsEvent( + id, + _xactId, + created, + orgId, + projectId, + logId, + input, + output, + expected, + error, + scores, + metadata, + tags.map { it.toUnmodifiable() }, + metrics, + context, + spanId, + spanParents.map { it.toUnmodifiable() }, + rootSpanId, + spanAttributes, + additionalProperties.toUnmodifiable(), + ) } - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class LogId @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is LogId && this.value == other.value + return other is LogId && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -709,34 +817,33 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - G -> Value.G - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + G -> Value.G + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - G -> Known.G - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } + fun known(): Known = when (this) { + G -> Known.G + else -> throw BraintrustInvalidDataException("Unknown LogId: $value") + } fun asString(): String = _value().asStringOrThrow() } /** - * 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 */ @JsonDeserialize(builder = Context.Builder::class) @NoAutoDetect - class Context - private constructor( - private val callerFunctionname: JsonField, - private val callerFilename: JsonField, - private val callerLineno: JsonField, - private val additionalProperties: Map, + class Context private constructor( + private val callerFunctionname: JsonField, + private val callerFilename: JsonField, + private val callerLineno: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -758,10 +865,14 @@ private constructor( fun _callerFunctionname() = callerFunctionname /** Name of the file in code where the project logs event was created */ - @JsonProperty("caller_filename") @ExcludeMissing fun _callerFilename() = callerFilename + @JsonProperty("caller_filename") + @ExcludeMissing + fun _callerFilename() = callerFilename /** Line of code where the project logs event was created */ - @JsonProperty("caller_lineno") @ExcludeMissing fun _callerLineno() = callerLineno + @JsonProperty("caller_lineno") + @ExcludeMissing + fun _callerLineno() = callerLineno @JsonAnyGetter @ExcludeMissing @@ -769,42 +880,40 @@ private constructor( fun validate(): Context = apply { if (!validated) { - callerFunctionname() - callerFilename() - callerLineno() - validated = true + callerFunctionname() + callerFilename() + callerLineno() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Context && - this.callerFunctionname == other.callerFunctionname && - this.callerFilename == other.callerFilename && - this.callerLineno == other.callerLineno && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Context && + this.callerFunctionname == other.callerFunctionname && + this.callerFilename == other.callerFilename && + this.callerLineno == other.callerLineno && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" + override fun toString() = "Context{callerFunctionname=$callerFunctionname, callerFilename=$callerFilename, callerLineno=$callerLineno, additionalProperties=$additionalProperties}" companion object { @@ -826,8 +935,7 @@ private constructor( } /** The function in code which created the project logs event */ - fun callerFunctionname(callerFunctionname: String) = - callerFunctionname(JsonField.of(callerFunctionname)) + fun callerFunctionname(callerFunctionname: String) = callerFunctionname(JsonField.of(callerFunctionname)) /** The function in code which created the project logs event */ @JsonProperty("caller_functionname") @@ -837,8 +945,7 @@ private constructor( } /** Name of the file in code where the project logs event was created */ - fun callerFilename(callerFilename: String) = - callerFilename(JsonField.of(callerFilename)) + fun callerFilename(callerFilename: String) = callerFilename(JsonField.of(callerFilename)) /** Name of the file in code where the project logs event was created */ @JsonProperty("caller_filename") @@ -871,29 +978,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Context = - Context( - callerFunctionname, - callerFilename, - callerLineno, - additionalProperties.toUnmodifiable(), - ) + fun build(): Context = Context( + callerFunctionname, + callerFilename, + callerLineno, + additionalProperties.toUnmodifiable(), + ) } } /** - * A dictionary with additional data about the test example, model outputs, or just about - * anything else that's relevant, that you can use to help find and analyze examples later. For - * example, you could log the `prompt`, example's `id`, or anything else 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 */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -905,25 +1008,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" @@ -960,20 +1064,20 @@ 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 */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics - private constructor( - private val start: JsonField, - private val end: JsonField, - private val promptTokens: JsonField, - private val completionTokens: JsonField, - private val tokens: JsonField, - private val additionalProperties: Map, + class Metrics private constructor( + private val start: JsonField, + private val end: JsonField, + private val promptTokens: JsonField, + private val completionTokens: JsonField, + private val tokens: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -981,26 +1085,26 @@ private constructor( private var hashCode: Int = 0 /** - * 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(): Double? = start.getNullable("start") /** - * 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(): Double? = 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(): Long? = promptTokens.getNullable("prompt_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) */ fun completionTokens(): Long? = completionTokens.getNullable("completion_tokens") @@ -1008,33 +1112,41 @@ private constructor( fun tokens(): Long? = tokens.getNullable("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 */ - @JsonProperty("start") @ExcludeMissing fun _start() = start + @JsonProperty("start") + @ExcludeMissing + fun _start() = start /** - * 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() = end + @JsonProperty("end") + @ExcludeMissing + fun _end() = end /** - * The number of tokens in the prompt used to generate the project logs event (only set if - * this is an LLM span) + * The number of tokens in the prompt used to generate the project logs event (only + * set if this is an LLM span) */ - @JsonProperty("prompt_tokens") @ExcludeMissing fun _promptTokens() = promptTokens + @JsonProperty("prompt_tokens") + @ExcludeMissing + fun _promptTokens() = promptTokens /** - * 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() = completionTokens /** The total number of tokens in the input and output of the project logs event. */ - @JsonProperty("tokens") @ExcludeMissing fun _tokens() = tokens + @JsonProperty("tokens") + @ExcludeMissing + fun _tokens() = tokens @JsonAnyGetter @ExcludeMissing @@ -1042,48 +1154,46 @@ private constructor( fun validate(): Metrics = apply { if (!validated) { - start() - end() - promptTokens() - completionTokens() - tokens() - validated = true + start() + end() + promptTokens() + completionTokens() + tokens() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metrics && - this.start == other.start && - this.end == other.end && - this.promptTokens == other.promptTokens && - this.completionTokens == other.completionTokens && - this.tokens == other.tokens && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Metrics && + this.start == other.start && + this.end == other.end && + this.promptTokens == other.promptTokens && + this.completionTokens == other.completionTokens && + this.tokens == other.tokens && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" + override fun toString() = "Metrics{start=$start, end=$end, promptTokens=$promptTokens, completionTokens=$completionTokens, tokens=$tokens, additionalProperties=$additionalProperties}" companion object { @@ -1109,42 +1219,46 @@ private constructor( } /** - * 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.of(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 */ @JsonProperty("start") @ExcludeMissing - fun start(start: JsonField) = apply { this.start = start } + fun start(start: JsonField) = apply { + this.start = start + } /** - * 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.of(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 */ @JsonProperty("end") @ExcludeMissing - 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.of(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) */ @JsonProperty("prompt_tokens") @ExcludeMissing @@ -1153,15 +1267,14 @@ private constructor( } /** - * 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.of(completionTokens)) + fun completionTokens(completionTokens: Long) = completionTokens(JsonField.of(completionTokens)) /** - * The number of tokens in the completion generated by the model (only set if this is an - * LLM span) + * The number of tokens in the completion generated by the model (only set if this + * is an LLM span) */ @JsonProperty("completion_tokens") @ExcludeMissing @@ -1175,7 +1288,9 @@ private constructor( /** The total number of tokens in the input and output of the project logs event. */ @JsonProperty("tokens") @ExcludeMissing - fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + fun tokens(tokens: JsonField) = apply { + this.tokens = tokens + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1191,33 +1306,30 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Metrics = - Metrics( - start, - end, - promptTokens, - completionTokens, - tokens, - additionalProperties.toUnmodifiable(), - ) + fun build(): Metrics = Metrics( + start, + end, + promptTokens, + completionTokens, + tokens, + additionalProperties.toUnmodifiable(), + ) } } /** - * 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. */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { + class Scores private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1229,25 +1341,26 @@ private constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" @@ -1286,12 +1399,7 @@ private constructor( /** Human-identifying attributes of the span, such as name, type, etc. */ @JsonDeserialize(builder = SpanAttributes.Builder::class) @NoAutoDetect - class SpanAttributes - private constructor( - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { + class SpanAttributes private constructor(private val name: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1304,10 +1412,14 @@ private constructor( fun type(): Type? = type.getNullable("type") /** Name of the span, for display purposes only */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Type of the span, for display purposes only */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1315,39 +1427,37 @@ private constructor( fun validate(): SpanAttributes = apply { if (!validated) { - name() - type() - validated = true + name() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SpanAttributes && - this.name == other.name && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SpanAttributes && + this.name == other.name && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "SpanAttributes{name=$name, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1372,7 +1482,9 @@ private constructor( /** Name of the span, for display purposes only */ @JsonProperty("name") @ExcludeMissing - 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.of(type)) @@ -1380,7 +1492,9 @@ private constructor( /** Type of the span, for display purposes only */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1396,28 +1510,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): SpanAttributes = - SpanAttributes( - name, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): SpanAttributes = SpanAttributes( + name, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1460,27 +1571,25 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - LLM -> Value.LLM - SCORE -> Value.SCORE - FUNCTION -> Value.FUNCTION - EVAL -> Value.EVAL - TASK -> Value.TASK - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM -> Known.LLM - SCORE -> Known.SCORE - FUNCTION -> Known.FUNCTION - EVAL -> Known.EVAL - TASK -> Known.TASK - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = when (this) { + LLM -> Value.LLM + SCORE -> Value.SCORE + FUNCTION -> Value.FUNCTION + EVAL -> Value.EVAL + TASK -> Value.TASK + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + LLM -> Known.LLM + SCORE -> Known.SCORE + FUNCTION -> Known.FUNCTION + EVAL -> Known.EVAL + TASK -> Known.TASK + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt index fb0a2f2f..af6610fa 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ProjectRetrieveParams -constructor( - private val projectId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class ProjectRetrieveParams constructor(private val projectId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun projectId(): String = projectId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectRetrieveParams && - this.projectId == other.projectId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ProjectRetrieveParams && + this.projectId == other.projectId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - projectId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + projectId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ProjectRetrieveParams{projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ProjectRetrieveParams{projectId=$projectId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): ProjectRetrieveParams = - ProjectRetrieveParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): ProjectRetrieveParams = ProjectRetrieveParams( + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt index 680e9193..edc1fc31 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScore.kt @@ -2,47 +2,56 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException -/** 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 + */ @JsonDeserialize(builder = ProjectScore.Builder::class) @NoAutoDetect -class ProjectScore -private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val scoreType: JsonField, - private val categories: JsonField, - private val config: JsonField, - private val position: JsonField, - private val additionalProperties: Map, +class ProjectScore private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val userId: JsonField, + private val created: JsonField, + private val name: JsonField, + private val description: JsonField, + private val scoreType: JsonField, + private val categories: JsonField, + private val config: JsonField, + private val position: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -73,35 +82,61 @@ private constructor( fun config(): Config? = config.getNullable("config") - /** 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(): String? = position.getNullable("position") /** Unique identifier for the project score */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId() = projectId - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId /** Date of project score creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Name of the project score */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Textual description of the project score */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description() = description /** The type of the configured score */ - @JsonProperty("score_type") @ExcludeMissing fun _scoreType() = scoreType + @JsonProperty("score_type") + @ExcludeMissing + fun _scoreType() = scoreType - @JsonProperty("categories") @ExcludeMissing fun _categories() = categories + @JsonProperty("categories") + @ExcludeMissing + fun _categories() = categories - @JsonProperty("config") @ExcludeMissing fun _config() = config + @JsonProperty("config") + @ExcludeMissing + fun _config() = config - /** An optional LexoRank-based string that sets the sort position for the score in the UI */ - @JsonProperty("position") @ExcludeMissing fun _position() = position + /** + * An optional LexoRank-based string that sets the sort position for the score in + * the UI + */ + @JsonProperty("position") + @ExcludeMissing + fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -109,63 +144,61 @@ private constructor( fun validate(): ProjectScore = apply { if (!validated) { - id() - projectId() - userId() - created() - name() - description() - scoreType() - categories() - config()?.validate() - position() - validated = true + id() + projectId() + userId() + created() + name() + description() + scoreType() + categories() + config()?.validate() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScore && - this.id == other.id && - this.projectId == other.projectId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.config == other.config && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectScore && + this.id == other.id && + this.projectId == other.projectId && + this.userId == other.userId && + this.created == other.created && + this.name == other.name && + this.description == other.description && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.config == other.config && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - projectId, - userId, - created, - name, - description, - scoreType, - categories, - config, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + projectId, + userId, + created, + name, + description, + scoreType, + categories, + config, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectScore{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, scoreType=$scoreType, categories=$categories, config=$config, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScore{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, scoreType=$scoreType, categories=$categories, config=$config, position=$position, additionalProperties=$additionalProperties}" companion object { @@ -204,7 +237,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project score */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** Unique identifier for the project that the project score belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -212,13 +249,17 @@ private constructor( /** Unique identifier for the project that the project score belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } fun userId(userId: String) = userId(JsonField.of(userId)) @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } /** Date of project score creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -226,7 +267,9 @@ private constructor( /** Date of project score creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** Name of the project score */ fun name(name: String) = name(JsonField.of(name)) @@ -234,7 +277,9 @@ private constructor( /** Name of the project score */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } /** Textual description of the project score */ fun description(description: String) = description(JsonField.of(description)) @@ -242,7 +287,9 @@ private constructor( /** Textual description of the project score */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } /** The type of the configured score */ fun scoreType(scoreType: ScoreType) = scoreType(JsonField.of(scoreType)) @@ -250,27 +297,41 @@ private constructor( /** The type of the configured score */ @JsonProperty("score_type") @ExcludeMissing - fun scoreType(scoreType: JsonField) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: JsonField) = apply { + this.scoreType = scoreType + } fun categories(categories: Categories) = categories(JsonField.of(categories)) @JsonProperty("categories") @ExcludeMissing - fun categories(categories: JsonField) = apply { this.categories = categories } + fun categories(categories: JsonField) = apply { + this.categories = categories + } fun config(config: Config) = config(JsonField.of(config)) @JsonProperty("config") @ExcludeMissing - fun config(config: JsonField) = apply { this.config = config } + fun config(config: JsonField) = apply { + this.config = config + } - /** 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.of(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 + */ @JsonProperty("position") @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } + fun position(position: JsonField) = apply { + this.position = position + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -286,36 +347,33 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectScore = - ProjectScore( - id, - projectId, - userId, - created, - name, - description, - scoreType, - categories, - config, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectScore = ProjectScore( + id, + projectId, + userId, + created, + name, + description, + scoreType, + categories, + config, + position, + additionalProperties.toUnmodifiable(), + ) } - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ScoreType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ScoreType && this.value == other.value + return other is ScoreType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -354,38 +412,36 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } + fun known(): Known = when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( - private val projectScoreCategories: List? = null, - private val weighted: Weighted? = null, - private val strings: List? = null, - private val nullableVariant: NullableVariant? = null, - private val _json: JsonValue? = null, + class Categories private constructor( + private val projectScoreCategories: List? = null, + private val weighted: Weighted? = null, + private val strings: List? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false @@ -396,100 +452,83 @@ private constructor( fun weighted(): Weighted? = weighted /** For minimum-type project scores, the list of included scores */ fun strings(): List? = strings - fun nullableVariant(): NullableVariant? = nullableVariant fun isProjectScoreCategories(): Boolean = projectScoreCategories != null - fun isWeighted(): Boolean = weighted != null - fun isStrings(): Boolean = strings != null - fun isNullableVariant(): Boolean = nullableVariant != null - fun asProjectScoreCategories(): List = - projectScoreCategories.getOrThrow("projectScoreCategories") - + fun asProjectScoreCategories(): List = projectScoreCategories.getOrThrow("projectScoreCategories") fun asWeighted(): Weighted = weighted.getOrThrow("weighted") - fun asStrings(): List = strings.getOrThrow("strings") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - projectScoreCategories != null -> - visitor.visitProjectScoreCategories(projectScoreCategories) - weighted != null -> visitor.visitWeighted(weighted) - strings != null -> visitor.visitStrings(strings) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + projectScoreCategories != null -> visitor.visitProjectScoreCategories(projectScoreCategories) + weighted != null -> visitor.visitWeighted(weighted) + strings != null -> visitor.visitStrings(strings) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Categories = apply { if (!validated) { - if ( - projectScoreCategories == null && - weighted == null && - strings == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - projectScoreCategories?.forEach { it.validate() } - weighted?.validate() - nullableVariant?.validate() - validated = true + if (projectScoreCategories == null && weighted == null && strings == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Categories: $_json") + } + projectScoreCategories?.forEach { it.validate() } + weighted?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.weighted == other.weighted && - this.strings == other.strings && - this.nullableVariant == other.nullableVariant + if (this === other) { + return true + } + + return other is Categories && + this.projectScoreCategories == other.projectScoreCategories && + this.weighted == other.weighted && + this.strings == other.strings && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - weighted, - strings, - nullableVariant, - ) + return Objects.hash( + projectScoreCategories, + weighted, + strings, + nullableVariant, + ) } override fun toString(): String { - return when { - projectScoreCategories != null -> - "Categories{projectScoreCategories=$projectScoreCategories}" - weighted != null -> "Categories{weighted=$weighted}" - strings != null -> "Categories{strings=$strings}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" - _json != null -> "Categories{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Categories") - } + return when { + projectScoreCategories != null -> "Categories{projectScoreCategories=$projectScoreCategories}" + weighted != null -> "Categories{weighted=$weighted}" + strings != null -> "Categories{strings=$strings}" + nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" + _json != null -> "Categories{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Categories") + } } companion object { - fun ofProjectScoreCategories(projectScoreCategories: List) = - Categories(projectScoreCategories = projectScoreCategories) + fun ofProjectScoreCategories(projectScoreCategories: List) = Categories(projectScoreCategories = projectScoreCategories) fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) fun ofStrings(strings: List) = Categories(strings = strings) - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } interface Visitor { @@ -503,62 +542,49 @@ private constructor( fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } 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(projectScoreCategories = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) - } - 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(projectScoreCategories = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(strings = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.projectScoreCategories != null -> - generator.writeObject(value.projectScoreCategories) - value.weighted != null -> generator.writeObject(value.weighted) - value.strings != null -> generator.writeObject(value.strings) - 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.projectScoreCategories != null -> generator.writeObject(value.projectScoreCategories) + value.weighted != null -> generator.writeObject(value.weighted) + value.strings != null -> generator.writeObject(value.strings) + 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 */ @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect - class Weighted - private constructor( - private val additionalProperties: Map, - ) { + class Weighted private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -570,25 +596,26 @@ private constructor( fun validate(): Weighted = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Weighted && this.additionalProperties == other.additionalProperties + return other is Weighted && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Weighted{additionalProperties=$additionalProperties}" @@ -616,10 +643,9 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } @@ -627,10 +653,7 @@ private constructor( @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class NullableVariant - private constructor( - private val additionalProperties: Map, - ) { + class NullableVariant private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -642,26 +665,26 @@ private constructor( fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is NullableVariant && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" @@ -689,25 +712,23 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = Config.Builder::class) @NoAutoDetect - class Config - private constructor( - private val multiSelect: JsonField, - private val destination: JsonField, - private val online: JsonField, - private val additionalProperties: Map, + class Config private constructor( + private val multiSelect: JsonField, + private val destination: JsonField, + private val online: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -720,11 +741,17 @@ private constructor( fun online(): Online? = online.getNullable("online") - @JsonProperty("multi_select") @ExcludeMissing fun _multiSelect() = multiSelect + @JsonProperty("multi_select") + @ExcludeMissing + fun _multiSelect() = multiSelect - @JsonProperty("destination") @ExcludeMissing fun _destination() = destination + @JsonProperty("destination") + @ExcludeMissing + fun _destination() = destination - @JsonProperty("online") @ExcludeMissing fun _online() = online + @JsonProperty("online") + @ExcludeMissing + fun _online() = online @JsonAnyGetter @ExcludeMissing @@ -732,42 +759,40 @@ private constructor( fun validate(): Config = apply { if (!validated) { - multiSelect() - destination() - online()?.validate() - validated = true + multiSelect() + destination() + online()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Config && - this.multiSelect == other.multiSelect && - this.destination == other.destination && - this.online == other.online && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Config && + this.multiSelect == other.multiSelect && + this.destination == other.destination && + this.online == other.online && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - multiSelect, - destination, - online, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + multiSelect, + destination, + online, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Config{multiSelect=$multiSelect, destination=$destination, online=$online, additionalProperties=$additionalProperties}" + override fun toString() = "Config{multiSelect=$multiSelect, destination=$destination, online=$online, additionalProperties=$additionalProperties}" companion object { @@ -808,7 +833,9 @@ private constructor( @JsonProperty("online") @ExcludeMissing - fun online(online: JsonField) = apply { this.online = online } + fun online(online: JsonField) = apply { + this.online = online + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -824,29 +851,26 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Config = - Config( - multiSelect, - destination, - online, - additionalProperties.toUnmodifiable(), - ) + fun build(): Config = Config( + multiSelect, + destination, + online, + additionalProperties.toUnmodifiable(), + ) } - class Destination - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Destination @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Destination && this.value == other.value + return other is Destination && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -869,30 +893,28 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - EXPECTED -> Value.EXPECTED - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + EXPECTED -> Value.EXPECTED + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - EXPECTED -> Known.EXPECTED - else -> throw BraintrustInvalidDataException("Unknown Destination: $value") - } + fun known(): Known = when (this) { + EXPECTED -> Known.EXPECTED + else -> throw BraintrustInvalidDataException("Unknown Destination: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = Online.Builder::class) @NoAutoDetect - class Online - private constructor( - private val samplingRate: JsonField, - private val scorers: JsonField>, - private val applyToRootSpan: JsonField, - private val applyToSpanNames: JsonField>, - private val additionalProperties: Map, + class Online private constructor( + private val samplingRate: JsonField, + private val scorers: JsonField>, + private val applyToRootSpan: JsonField, + private val applyToSpanNames: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -909,14 +931,17 @@ private constructor( fun applyToRootSpan(): Boolean? = applyToRootSpan.getNullable("apply_to_root_span") /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(): List? = - applyToSpanNames.getNullable("apply_to_span_names") + fun applyToSpanNames(): List? = applyToSpanNames.getNullable("apply_to_span_names") /** The sampling rate for online scoring */ - @JsonProperty("sampling_rate") @ExcludeMissing fun _samplingRate() = samplingRate + @JsonProperty("sampling_rate") + @ExcludeMissing + fun _samplingRate() = samplingRate /** The list of scorers to use for online scoring */ - @JsonProperty("scorers") @ExcludeMissing fun _scorers() = scorers + @JsonProperty("scorers") + @ExcludeMissing + fun _scorers() = scorers /** Whether to trigger online scoring on the root span of each trace */ @JsonProperty("apply_to_root_span") @@ -934,45 +959,43 @@ private constructor( fun validate(): Online = apply { if (!validated) { - samplingRate() - scorers() - applyToRootSpan() - applyToSpanNames() - validated = true + samplingRate() + scorers() + applyToRootSpan() + applyToSpanNames() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Online && - this.samplingRate == other.samplingRate && - this.scorers == other.scorers && - this.applyToRootSpan == other.applyToRootSpan && - this.applyToSpanNames == other.applyToSpanNames && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Online && + this.samplingRate == other.samplingRate && + this.scorers == other.scorers && + this.applyToRootSpan == other.applyToRootSpan && + this.applyToSpanNames == other.applyToSpanNames && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - samplingRate, - scorers, - applyToRootSpan, - applyToSpanNames, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + samplingRate, + scorers, + applyToRootSpan, + applyToSpanNames, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Online{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" + override fun toString() = "Online{samplingRate=$samplingRate, scorers=$scorers, applyToRootSpan=$applyToRootSpan, applyToSpanNames=$applyToSpanNames, additionalProperties=$additionalProperties}" companion object { @@ -1011,11 +1034,12 @@ private constructor( /** The list of scorers to use for online scoring */ @JsonProperty("scorers") @ExcludeMissing - fun scorers(scorers: JsonField>) = apply { this.scorers = scorers } + fun scorers(scorers: JsonField>) = apply { + this.scorers = scorers + } /** Whether to trigger online scoring on the root span of each trace */ - fun applyToRootSpan(applyToRootSpan: Boolean) = - applyToRootSpan(JsonField.of(applyToRootSpan)) + fun applyToRootSpan(applyToRootSpan: Boolean) = applyToRootSpan(JsonField.of(applyToRootSpan)) /** Whether to trigger online scoring on the root span of each trace */ @JsonProperty("apply_to_root_span") @@ -1025,8 +1049,7 @@ private constructor( } /** Trigger online scoring on any spans with a name in this list */ - fun applyToSpanNames(applyToSpanNames: List) = - applyToSpanNames(JsonField.of(applyToSpanNames)) + fun applyToSpanNames(applyToSpanNames: List) = applyToSpanNames(JsonField.of(applyToSpanNames)) /** Trigger online scoring on any spans with a name in this list */ @JsonProperty("apply_to_span_names") @@ -1045,86 +1068,76 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Online = - Online( - samplingRate, - scorers.map { it.toUnmodifiable() }, - applyToRootSpan, - applyToSpanNames.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Online = Online( + samplingRate, + scorers.map { it.toUnmodifiable() }, + applyToRootSpan, + applyToSpanNames.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Scorer.Deserializer::class) @JsonSerialize(using = Scorer.Serializer::class) - class Scorer - private constructor( - private val function: Function? = null, - private val global: Global? = null, - private val _json: JsonValue? = null, - ) { + class Scorer private constructor(private val function: Function? = null, private val global: Global? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun function(): Function? = function - fun global(): Global? = global fun isFunction(): Boolean = function != null - fun isGlobal(): Boolean = global != null fun asFunction(): Function = function.getOrThrow("function") - fun asGlobal(): Global = global.getOrThrow("global") fun _json(): JsonValue? = _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) + } } fun validate(): Scorer = apply { if (!validated) { - if (function == null && global == null) { - throw BraintrustInvalidDataException("Unknown Scorer: $_json") - } - function?.validate() - global?.validate() - validated = true + if (function == null && global == null) { + throw BraintrustInvalidDataException("Unknown Scorer: $_json") + } + function?.validate() + global?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scorer && - this.function == other.function && - this.global == other.global + return other is Scorer && + this.function == other.function && + this.global == other.global } override fun hashCode(): Int { - return Objects.hash(function, global) + return Objects.hash(function, global) } override fun toString(): String { - return when { - function != null -> "Scorer{function=$function}" - global != null -> "Scorer{global=$global}" - _json != null -> "Scorer{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Scorer") - } + return when { + function != null -> "Scorer{function=$function}" + global != null -> "Scorer{global=$global}" + _json != null -> "Scorer{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Scorer") + } } companion object { @@ -1141,51 +1154,40 @@ private constructor( fun visitGlobal(global: Global): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Scorer: $json") + throw BraintrustInvalidDataException("Unknown Scorer: $json") } } class Deserializer : BaseDeserializer(Scorer::class) { override fun ObjectCodec.deserialize(node: JsonNode): Scorer { - 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) - } - - return Scorer(_json = json) + 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) + } + + return Scorer(_json = json) } } 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") + } } } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function - private constructor( - private val type: JsonField, - private val id: JsonField, - private val additionalProperties: Map, - ) { + class Function private constructor(private val type: JsonField, private val id: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1195,9 +1197,13 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id @JsonAnyGetter @ExcludeMissing @@ -1205,39 +1211,37 @@ private constructor( fun validate(): Function = apply { if (!validated) { - type() - id() - validated = true + type() + id() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.type == other.type && - this.id == other.id && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Function && + this.type == other.type && + this.id == other.id && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - id, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + id, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" + override fun toString() = "Function{type=$type, id=$id, additionalProperties=$additionalProperties}" companion object { @@ -1248,8 +1252,7 @@ private constructor( private var type: JsonField = JsonMissing.of() private var id: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(function: Function) = apply { this.type = function.type @@ -1261,52 +1264,51 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun id(id: String) = id(JsonField.of(id)) @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { + this.id = id + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Function = - Function( - type, - id, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = Function( + type, + id, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1329,17 +1331,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + FUNCTION -> Known.FUNCTION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1347,12 +1347,7 @@ private constructor( @JsonDeserialize(builder = Global.Builder::class) @NoAutoDetect - class Global - private constructor( - private val type: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { + class Global private constructor(private val type: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1362,9 +1357,13 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing @@ -1372,39 +1371,37 @@ private constructor( fun validate(): Global = apply { if (!validated) { - type() - name() - validated = true + type() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Global && - this.type == other.type && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Global && + this.type == other.type && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Global{type=$type, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -1415,8 +1412,7 @@ private constructor( private var type: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(global: Global) = apply { this.type = global.type @@ -1428,52 +1424,51 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Global = - Global( - type, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Global = Global( + type, + name, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1496,17 +1491,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - GLOBAL -> Value.GLOBAL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - GLOBAL -> Known.GLOBAL - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun value(): Value = when (this) { + GLOBAL -> Value.GLOBAL + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + GLOBAL -> Known.GLOBAL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt index ef0de1ca..298db90e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCategory.kt @@ -2,27 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** For categorical-type project scores, defines a single category */ @JsonDeserialize(builder = ProjectScoreCategory.Builder::class) @NoAutoDetect -class ProjectScoreCategory -private constructor( - private val name: JsonField, - private val value: JsonField, - private val additionalProperties: Map, -) { +class ProjectScoreCategory private constructor(private val name: JsonField, private val value: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -35,10 +49,14 @@ private constructor( fun value(): Double = value.getRequired("value") /** Name of the category */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Numerical value of the category. Must be between 0 and 1, inclusive */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") + @ExcludeMissing + fun _value() = value @JsonAnyGetter @ExcludeMissing @@ -46,39 +64,37 @@ private constructor( fun validate(): ProjectScoreCategory = apply { if (!validated) { - name() - value() - validated = true + name() + value() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreCategory && - this.name == other.name && - this.value == other.value && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectScoreCategory && + this.name == other.name && + this.value == other.value && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - value, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + value, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScoreCategory{name=$name, value=$value, additionalProperties=$additionalProperties}" companion object { @@ -103,7 +119,9 @@ private constructor( /** Name of the category */ @JsonProperty("name") @ExcludeMissing - 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)) @@ -111,7 +129,9 @@ private constructor( /** Numerical value of the category. Must be between 0 and 1, inclusive */ @JsonProperty("value") @ExcludeMissing - fun value(value: JsonField) = apply { this.value = value } + fun value(value: JsonField) = apply { + this.value = value + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -127,11 +147,10 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectScoreCategory = - ProjectScoreCategory( - name, - value, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreCategory = ProjectScoreCategory( + name, + value, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt index c9d70658..34f45a1a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParams.kt @@ -2,40 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectScoreCreateParams constructor( + private val name: String, + private val projectId: String, + private val scoreType: ScoreType?, + private val categories: Categories?, + private val description: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectScoreCreateParams -constructor( - private val name: String, - private val projectId: String, - private val scoreType: ScoreType?, - private val categories: Categories?, - private val description: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -49,14 +59,14 @@ constructor( fun description(): String? = description internal fun getBody(): ProjectScoreCreateBody { - return ProjectScoreCreateBody( - name, - projectId, - scoreType, - categories, - description, - additionalBodyProperties, - ) + return ProjectScoreCreateBody( + name, + projectId, + scoreType, + categories, + description, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -65,31 +75,36 @@ constructor( @JsonDeserialize(builder = ProjectScoreCreateBody.Builder::class) @NoAutoDetect - class ProjectScoreCreateBody - internal constructor( - private val name: String?, - private val projectId: String?, - private val scoreType: ScoreType?, - private val categories: Categories?, - private val description: String?, - private val additionalProperties: Map, + class ProjectScoreCreateBody internal constructor( + private val name: String?, + private val projectId: String?, + private val scoreType: ScoreType?, + private val categories: Categories?, + private val description: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the project score */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") + fun projectId(): String? = projectId /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") + fun scoreType(): ScoreType? = scoreType - @JsonProperty("categories") fun categories(): Categories? = categories + @JsonProperty("categories") + fun categories(): Categories? = categories /** Textual description of the project score */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description @JsonAnyGetter @ExcludeMissing @@ -98,36 +113,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectScoreCreateBody && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.description == other.description && - this.additionalProperties == other.additionalProperties + return other is ProjectScoreCreateBody && + this.name == other.name && + this.projectId == other.projectId && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.description == other.description && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - scoreType, - categories, - description, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + projectId, + scoreType, + categories, + description, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScoreCreateBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalProperties=$additionalProperties}" companion object { @@ -153,22 +166,33 @@ constructor( } /** Name of the project score */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the project score belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { + this.scoreType = scoreType + } @JsonProperty("categories") - fun categories(categories: Categories) = apply { this.categories = categories } + fun categories(categories: Categories) = apply { + this.categories = categories + } /** Textual description of the project score */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -184,15 +208,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectScoreCreateBody = - ProjectScoreCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - scoreType, - categories, - description, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreCreateBody = ProjectScoreCreateBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + scoreType, + categories, + description, + additionalProperties.toUnmodifiable(), + ) } } @@ -203,36 +230,35 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreCreateParams && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectScoreCreateParams && + this.name == other.name && + this.projectId == other.projectId && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.description == other.description && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - scoreType, - categories, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + scoreType, + categories, + description, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectScoreCreateParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectScoreCreateParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -265,16 +291,24 @@ constructor( } /** Name of the project score */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { + this.scoreType = scoreType + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { this.categories = categories } + fun categories(categories: Categories) = apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ fun categories(projectScoreCategories: List) = apply { @@ -297,7 +331,9 @@ constructor( } /** Textual description of the project score */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -337,7 +373,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -348,38 +386,38 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectScoreCreateParams = - ProjectScoreCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - scoreType, - categories, - description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreCreateParams = ProjectScoreCreateParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + scoreType, + categories, + description, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ScoreType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ScoreType && this.value == other.value + return other is ScoreType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -418,38 +456,36 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } + fun known(): Known = when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( - private val projectScoreCategories: List? = null, - private val weighted: Weighted? = null, - private val strings: List? = null, - private val nullableVariant: NullableVariant? = null, - private val _json: JsonValue? = null, + class Categories private constructor( + private val projectScoreCategories: List? = null, + private val weighted: Weighted? = null, + private val strings: List? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false @@ -460,100 +496,83 @@ constructor( fun weighted(): Weighted? = weighted /** For minimum-type project scores, the list of included scores */ fun strings(): List? = strings - fun nullableVariant(): NullableVariant? = nullableVariant fun isProjectScoreCategories(): Boolean = projectScoreCategories != null - fun isWeighted(): Boolean = weighted != null - fun isStrings(): Boolean = strings != null - fun isNullableVariant(): Boolean = nullableVariant != null - fun asProjectScoreCategories(): List = - projectScoreCategories.getOrThrow("projectScoreCategories") - + fun asProjectScoreCategories(): List = projectScoreCategories.getOrThrow("projectScoreCategories") fun asWeighted(): Weighted = weighted.getOrThrow("weighted") - fun asStrings(): List = strings.getOrThrow("strings") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - projectScoreCategories != null -> - visitor.visitProjectScoreCategories(projectScoreCategories) - weighted != null -> visitor.visitWeighted(weighted) - strings != null -> visitor.visitStrings(strings) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + projectScoreCategories != null -> visitor.visitProjectScoreCategories(projectScoreCategories) + weighted != null -> visitor.visitWeighted(weighted) + strings != null -> visitor.visitStrings(strings) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Categories = apply { if (!validated) { - if ( - projectScoreCategories == null && - weighted == null && - strings == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - projectScoreCategories?.forEach { it.validate() } - weighted?.validate() - nullableVariant?.validate() - validated = true + if (projectScoreCategories == null && weighted == null && strings == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Categories: $_json") + } + projectScoreCategories?.forEach { it.validate() } + weighted?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.weighted == other.weighted && - this.strings == other.strings && - this.nullableVariant == other.nullableVariant + return other is Categories && + this.projectScoreCategories == other.projectScoreCategories && + this.weighted == other.weighted && + this.strings == other.strings && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - weighted, - strings, - nullableVariant, - ) + return Objects.hash( + projectScoreCategories, + weighted, + strings, + nullableVariant, + ) } override fun toString(): String { - return when { - projectScoreCategories != null -> - "Categories{projectScoreCategories=$projectScoreCategories}" - weighted != null -> "Categories{weighted=$weighted}" - strings != null -> "Categories{strings=$strings}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" - _json != null -> "Categories{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Categories") - } + return when { + projectScoreCategories != null -> "Categories{projectScoreCategories=$projectScoreCategories}" + weighted != null -> "Categories{weighted=$weighted}" + strings != null -> "Categories{strings=$strings}" + nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" + _json != null -> "Categories{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Categories") + } } companion object { - fun ofProjectScoreCategories(projectScoreCategories: List) = - Categories(projectScoreCategories = projectScoreCategories) + fun ofProjectScoreCategories(projectScoreCategories: List) = Categories(projectScoreCategories = projectScoreCategories) fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) fun ofStrings(strings: List) = Categories(strings = strings) - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } interface Visitor { @@ -567,62 +586,49 @@ constructor( fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } 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(projectScoreCategories = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) - } - 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(projectScoreCategories = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(strings = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.projectScoreCategories != null -> - generator.writeObject(value.projectScoreCategories) - value.weighted != null -> generator.writeObject(value.weighted) - value.strings != null -> generator.writeObject(value.strings) - 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.projectScoreCategories != null -> generator.writeObject(value.projectScoreCategories) + value.weighted != null -> generator.writeObject(value.weighted) + value.strings != null -> generator.writeObject(value.strings) + 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 */ @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect - class Weighted - private constructor( - private val additionalProperties: Map, - ) { + class Weighted private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -634,25 +640,26 @@ constructor( fun validate(): Weighted = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Weighted && this.additionalProperties == other.additionalProperties + return other is Weighted && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Weighted{additionalProperties=$additionalProperties}" @@ -680,10 +687,9 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } @@ -691,10 +697,7 @@ constructor( @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class NullableVariant - private constructor( - private val additionalProperties: Map, - ) { + class NullableVariant private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -706,26 +709,26 @@ constructor( fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is NullableVariant && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" @@ -753,13 +756,11 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt index 43d18046..49b9e9de 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ProjectScoreDeleteParams -constructor( - private val projectScoreId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectScoreDeleteParams constructor( + private val projectScoreId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun projectScoreId(): String = projectScoreId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreDeleteParams && - this.projectScoreId == other.projectScoreId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectScoreDeleteParams && + this.projectScoreId == other.projectScoreId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectScoreId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectScoreId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectScoreDeleteParams{projectScoreId=$projectScoreId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } + fun projectScoreId(projectScoreId: String) = apply { + this.projectScoreId = projectScoreId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectScoreDeleteParams = - ProjectScoreDeleteParams( - checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectScoreDeleteParams = ProjectScoreDeleteParams( + checkNotNull(projectScoreId) { + "`projectScoreId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt index 86b67f72..740a2b41 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPage.kt @@ -2,107 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.services.blocking.ProjectScoreService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class ProjectScoreListPage -private constructor( - private val projectScoreService: ProjectScoreService, - private val params: ProjectScoreListParams, - private val response: Response, -) { +class ProjectScoreListPage private constructor(private val projectScoreService: ProjectScoreService, private val params: ProjectScoreListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreListPage && - this.projectScoreService == other.projectScoreService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectScoreListPage && + this.projectScoreService == other.projectScoreService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectScoreService, - params, - response, - ) + return Objects.hash( + projectScoreService, + params, + response, + ) } - override fun toString() = - "ProjectScoreListPage{projectScoreService=$projectScoreService, params=$params, response=$response}" + override fun toString() = "ProjectScoreListPage{projectScoreService=$projectScoreService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ProjectScoreListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ProjectScoreListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - } else { - ProjectScoreListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ProjectScoreListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ProjectScoreListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): ProjectScoreListPage? { - return getNextPageParams()?.let { projectScoreService.list(it) } + return getNextPageParams()?.let { + projectScoreService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - projectScoreService: ProjectScoreService, - params: ProjectScoreListParams, - response: Response - ) = - ProjectScoreListPage( - projectScoreService, - params, - response, - ) + fun of(projectScoreService: ProjectScoreService, params: ProjectScoreListParams, response: Response) = ProjectScoreListPage( + projectScoreService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -110,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ProjectScoreListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScoreListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -163,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ProjectScoreListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: ProjectScoreListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt index 621532d9..1c0e446c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListPageAsync.kt @@ -2,109 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.ProjectScoreServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.ProjectScore +import com.braintrustdata.api.services.async.ProjectScoreServiceAsync -class ProjectScoreListPageAsync -private constructor( - private val projectScoreService: ProjectScoreServiceAsync, - private val params: ProjectScoreListParams, - private val response: Response, -) { +class ProjectScoreListPageAsync private constructor(private val projectScoreService: ProjectScoreServiceAsync, private val params: ProjectScoreListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreListPageAsync && - this.projectScoreService == other.projectScoreService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectScoreListPageAsync && + this.projectScoreService == other.projectScoreService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectScoreService, - params, - response, - ) + return Objects.hash( + projectScoreService, + params, + response, + ) } - override fun toString() = - "ProjectScoreListPageAsync{projectScoreService=$projectScoreService, params=$params, response=$response}" + override fun toString() = "ProjectScoreListPageAsync{projectScoreService=$projectScoreService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ProjectScoreListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ProjectScoreListParams.builder() - .from(params) - .endingBefore(objects().first().id()) - .build() - } else { - ProjectScoreListParams.builder() - .from(params) - .startingAfter(objects().last().id()) - .build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ProjectScoreListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ProjectScoreListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): ProjectScoreListPageAsync? { - return getNextPageParams()?.let { projectScoreService.list(it) } + return getNextPageParams()?.let { + projectScoreService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - projectScoreService: ProjectScoreServiceAsync, - params: ProjectScoreListParams, - response: Response - ) = - ProjectScoreListPageAsync( - projectScoreService, - params, - response, - ) + fun of(projectScoreService: ProjectScoreServiceAsync, params: ProjectScoreListParams, response: Response) = ProjectScoreListPageAsync( + projectScoreService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -112,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ProjectScoreListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScoreListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -165,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ProjectScoreListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: ProjectScoreListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt index 70708fc2..82094b4f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreListParams.kt @@ -2,39 +2,53 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectScoreListParams constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectId: String?, + private val projectName: String?, + private val projectScoreName: String?, + private val scoreType: ScoreType?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class ProjectScoreListParams -constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectId: String?, - private val projectName: String?, - private val projectScoreName: String?, - private val scoreType: ScoreType?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun endingBefore(): String? = endingBefore @@ -56,18 +70,36 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.projectScoreName?.let { params.put("project_score_name", listOf(it.toString())) } - this.scoreType?.let { params.put("score_type", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.projectId?.let { + params.put("project_id", listOf(it.toString())) + } + this.projectName?.let { + params.put("project_name", listOf(it.toString())) + } + this.projectScoreName?.let { + params.put("project_score_name", listOf(it.toString())) + } + this.scoreType?.let { + params.put("score_type", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -77,42 +109,41 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.projectScoreName == other.projectScoreName && - this.scoreType == other.scoreType && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ProjectScoreListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectId == other.projectId && + this.projectName == other.projectName && + this.projectScoreName == other.projectScoreName && + this.scoreType == other.scoreType && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectScoreName, - scoreType, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + projectScoreName, + scoreType, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ProjectScoreListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectScoreName=$projectScoreName, scoreType=$scoreType, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -153,41 +184,57 @@ 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** 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_score to search for */ fun projectScoreName(projectScoreName: String) = apply { @@ -195,7 +242,9 @@ constructor( } /** 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(unionMember0: ScoreType.UnionMember0) = apply { @@ -203,20 +252,20 @@ constructor( } /** The type of the configured score */ - fun scoreType(unnamedSchemaWithArrayParent0s: List) = - apply { - this.scoreType = - ScoreType.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) - } + fun scoreType(unnamedSchemaWithArrayParent0s: List) = apply { + this.scoreType = ScoreType.ofUnnamedSchemaWithArrayParent0s(unnamedSchemaWithArrayParent0s) + } /** * 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -256,85 +305,80 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): ProjectScoreListParams = - ProjectScoreListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectScoreName, - scoreType, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): ProjectScoreListParams = ProjectScoreListParams( + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + projectScoreName, + scoreType, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -351,180 +395,154 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + 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") + } } } } @JsonDeserialize(using = ScoreType.Deserializer::class) @JsonSerialize(using = ScoreType.Serializer::class) - class ScoreType - private constructor( - private val unionMember0: UnionMember0? = null, - private val unnamedSchemaWithArrayParent1s: List? = null, - private val _json: JsonValue? = null, - ) { + class ScoreType private constructor(private val unionMember0: UnionMember0? = null, private val unnamedSchemaWithArrayParent1s: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false /** The type of the configured score */ fun unionMember0(): UnionMember0? = unionMember0 /** The type of the configured score */ - fun unnamedSchemaWithArrayParent1s(): List? = - unnamedSchemaWithArrayParent1s + fun unnamedSchemaWithArrayParent1s(): List? = unnamedSchemaWithArrayParent1s fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnnamedSchemaWithArrayParent1s(): Boolean = unnamedSchemaWithArrayParent1s != null fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnnamedSchemaWithArrayParent1s(): List = - unnamedSchemaWithArrayParent1s.getOrThrow("unnamedSchemaWithArrayParent1s") + fun asUnnamedSchemaWithArrayParent1s(): List = unnamedSchemaWithArrayParent1s.getOrThrow("unnamedSchemaWithArrayParent1s") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unnamedSchemaWithArrayParent1s != null -> - visitor.visitUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) - else -> visitor.unknown(_json) - } + return when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + unnamedSchemaWithArrayParent1s != null -> visitor.visitUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s) + else -> visitor.unknown(_json) + } } fun validate(): ScoreType = apply { if (!validated) { - if (unionMember0 == null && unnamedSchemaWithArrayParent1s == null) { - throw BraintrustInvalidDataException("Unknown ScoreType: $_json") - } - validated = true + if (unionMember0 == null && unnamedSchemaWithArrayParent1s == null) { + throw BraintrustInvalidDataException("Unknown ScoreType: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ScoreType && - this.unionMember0 == other.unionMember0 && - this.unnamedSchemaWithArrayParent1s == other.unnamedSchemaWithArrayParent1s + return other is ScoreType && + this.unionMember0 == other.unionMember0 && + this.unnamedSchemaWithArrayParent1s == other.unnamedSchemaWithArrayParent1s } override fun hashCode(): Int { - return Objects.hash(unionMember0, unnamedSchemaWithArrayParent1s) + return Objects.hash(unionMember0, unnamedSchemaWithArrayParent1s) } override fun toString(): String { - return when { - unionMember0 != null -> "ScoreType{unionMember0=$unionMember0}" - unnamedSchemaWithArrayParent1s != null -> - "ScoreType{unnamedSchemaWithArrayParent1s=$unnamedSchemaWithArrayParent1s}" - _json != null -> "ScoreType{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ScoreType") - } + return when { + unionMember0 != null -> "ScoreType{unionMember0=$unionMember0}" + unnamedSchemaWithArrayParent1s != null -> "ScoreType{unnamedSchemaWithArrayParent1s=$unnamedSchemaWithArrayParent1s}" + _json != null -> "ScoreType{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ScoreType") + } } companion object { fun ofUnionMember0(unionMember0: UnionMember0) = ScoreType(unionMember0 = unionMember0) - fun ofUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ) = ScoreType(unnamedSchemaWithArrayParent1s = unnamedSchemaWithArrayParent1s) + fun ofUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s: List) = ScoreType(unnamedSchemaWithArrayParent1s = unnamedSchemaWithArrayParent1s) } interface Visitor { fun visitUnionMember0(unionMember0: UnionMember0): T - fun visitUnnamedSchemaWithArrayParent1s( - unnamedSchemaWithArrayParent1s: List - ): T + fun visitUnnamedSchemaWithArrayParent1s(unnamedSchemaWithArrayParent1s: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ScoreType: $json") + throw BraintrustInvalidDataException("Unknown ScoreType: $json") } } class Deserializer : BaseDeserializer(ScoreType::class) { override fun ObjectCodec.deserialize(node: JsonNode): ScoreType { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ScoreType(unionMember0 = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return ScoreType(unnamedSchemaWithArrayParent1s = it, _json = json) - } - - return ScoreType(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ScoreType(unionMember0 = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return ScoreType(unnamedSchemaWithArrayParent1s = it, _json = json) + } + + return ScoreType(_json = json) } } class Serializer : BaseSerializer(ScoreType::class) { - override fun serialize( - value: ScoreType, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unnamedSchemaWithArrayParent1s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent1s) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ScoreType") - } + override fun serialize(value: ScoreType, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.unnamedSchemaWithArrayParent1s != null -> generator.writeObject(value.unnamedSchemaWithArrayParent1s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ScoreType") + } } } - class UnionMember0 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class UnionMember0 @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnionMember0 && this.value == other.value + return other is UnionMember0 && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -563,43 +581,39 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") - } + fun value(): Value = when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown UnionMember0: $value") + } fun asString(): String = _value().asStringOrThrow() } - class UnnamedSchemaWithArrayParent1 - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class UnnamedSchemaWithArrayParent1 @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnnamedSchemaWithArrayParent1 && this.value == other.value + return other is UnnamedSchemaWithArrayParent1 && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -638,28 +652,23 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent1: $value" - ) - } + fun value(): Value = when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent1: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt index 619e863c..0595120a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParams.kt @@ -2,40 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectScoreReplaceParams constructor( + private val name: String, + private val projectId: String, + private val scoreType: ScoreType?, + private val categories: Categories?, + private val description: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectScoreReplaceParams -constructor( - private val name: String, - private val projectId: String, - private val scoreType: ScoreType?, - private val categories: Categories?, - private val description: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -49,14 +59,14 @@ constructor( fun description(): String? = description internal fun getBody(): ProjectScoreReplaceBody { - return ProjectScoreReplaceBody( - name, - projectId, - scoreType, - categories, - description, - additionalBodyProperties, - ) + return ProjectScoreReplaceBody( + name, + projectId, + scoreType, + categories, + description, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -65,31 +75,36 @@ constructor( @JsonDeserialize(builder = ProjectScoreReplaceBody.Builder::class) @NoAutoDetect - class ProjectScoreReplaceBody - internal constructor( - private val name: String?, - private val projectId: String?, - private val scoreType: ScoreType?, - private val categories: Categories?, - private val description: String?, - private val additionalProperties: Map, + class ProjectScoreReplaceBody internal constructor( + private val name: String?, + private val projectId: String?, + private val scoreType: ScoreType?, + private val categories: Categories?, + private val description: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the project score */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Unique identifier for the project that the project score belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") + fun projectId(): String? = projectId /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") + fun scoreType(): ScoreType? = scoreType - @JsonProperty("categories") fun categories(): Categories? = categories + @JsonProperty("categories") + fun categories(): Categories? = categories /** Textual description of the project score */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description @JsonAnyGetter @ExcludeMissing @@ -98,36 +113,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectScoreReplaceBody && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.description == other.description && - this.additionalProperties == other.additionalProperties + return other is ProjectScoreReplaceBody && + this.name == other.name && + this.projectId == other.projectId && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.description == other.description && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - scoreType, - categories, - description, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + projectId, + scoreType, + categories, + description, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScoreReplaceBody{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalProperties=$additionalProperties}" companion object { @@ -153,22 +166,33 @@ constructor( } /** Name of the project score */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the project score belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { + this.scoreType = scoreType + } @JsonProperty("categories") - fun categories(categories: Categories) = apply { this.categories = categories } + fun categories(categories: Categories) = apply { + this.categories = categories + } /** Textual description of the project score */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -184,15 +208,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectScoreReplaceBody = - ProjectScoreReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - scoreType, - categories, - description, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreReplaceBody = ProjectScoreReplaceBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + scoreType, + categories, + description, + additionalProperties.toUnmodifiable(), + ) } } @@ -203,36 +230,35 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreReplaceParams && - this.name == other.name && - this.projectId == other.projectId && - this.scoreType == other.scoreType && - this.categories == other.categories && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectScoreReplaceParams && + this.name == other.name && + this.projectId == other.projectId && + this.scoreType == other.scoreType && + this.categories == other.categories && + this.description == other.description && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - scoreType, - categories, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + scoreType, + categories, + description, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectScoreReplaceParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectScoreReplaceParams{name=$name, projectId=$projectId, scoreType=$scoreType, categories=$categories, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -265,16 +291,24 @@ constructor( } /** Name of the project score */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the project score belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { + this.scoreType = scoreType + } /** For categorical-type project scores, the list of all categories */ - fun categories(categories: Categories) = apply { this.categories = categories } + fun categories(categories: Categories) = apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ fun categories(projectScoreCategories: List) = apply { @@ -297,7 +331,9 @@ constructor( } /** Textual description of the project score */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -337,7 +373,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -348,38 +386,38 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectScoreReplaceParams = - ProjectScoreReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - scoreType, - categories, - description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreReplaceParams = ProjectScoreReplaceParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + scoreType, + categories, + description, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ScoreType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ScoreType && this.value == other.value + return other is ScoreType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -418,38 +456,36 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } + fun known(): Known = when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( - private val projectScoreCategories: List? = null, - private val weighted: Weighted? = null, - private val strings: List? = null, - private val nullableVariant: NullableVariant? = null, - private val _json: JsonValue? = null, + class Categories private constructor( + private val projectScoreCategories: List? = null, + private val weighted: Weighted? = null, + private val strings: List? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false @@ -460,100 +496,83 @@ constructor( fun weighted(): Weighted? = weighted /** For minimum-type project scores, the list of included scores */ fun strings(): List? = strings - fun nullableVariant(): NullableVariant? = nullableVariant fun isProjectScoreCategories(): Boolean = projectScoreCategories != null - fun isWeighted(): Boolean = weighted != null - fun isStrings(): Boolean = strings != null - fun isNullableVariant(): Boolean = nullableVariant != null - fun asProjectScoreCategories(): List = - projectScoreCategories.getOrThrow("projectScoreCategories") - + fun asProjectScoreCategories(): List = projectScoreCategories.getOrThrow("projectScoreCategories") fun asWeighted(): Weighted = weighted.getOrThrow("weighted") - fun asStrings(): List = strings.getOrThrow("strings") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - projectScoreCategories != null -> - visitor.visitProjectScoreCategories(projectScoreCategories) - weighted != null -> visitor.visitWeighted(weighted) - strings != null -> visitor.visitStrings(strings) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + projectScoreCategories != null -> visitor.visitProjectScoreCategories(projectScoreCategories) + weighted != null -> visitor.visitWeighted(weighted) + strings != null -> visitor.visitStrings(strings) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Categories = apply { if (!validated) { - if ( - projectScoreCategories == null && - weighted == null && - strings == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - projectScoreCategories?.forEach { it.validate() } - weighted?.validate() - nullableVariant?.validate() - validated = true + if (projectScoreCategories == null && weighted == null && strings == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Categories: $_json") + } + projectScoreCategories?.forEach { it.validate() } + weighted?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.weighted == other.weighted && - this.strings == other.strings && - this.nullableVariant == other.nullableVariant + return other is Categories && + this.projectScoreCategories == other.projectScoreCategories && + this.weighted == other.weighted && + this.strings == other.strings && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - weighted, - strings, - nullableVariant, - ) + return Objects.hash( + projectScoreCategories, + weighted, + strings, + nullableVariant, + ) } override fun toString(): String { - return when { - projectScoreCategories != null -> - "Categories{projectScoreCategories=$projectScoreCategories}" - weighted != null -> "Categories{weighted=$weighted}" - strings != null -> "Categories{strings=$strings}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" - _json != null -> "Categories{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Categories") - } + return when { + projectScoreCategories != null -> "Categories{projectScoreCategories=$projectScoreCategories}" + weighted != null -> "Categories{weighted=$weighted}" + strings != null -> "Categories{strings=$strings}" + nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" + _json != null -> "Categories{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Categories") + } } companion object { - fun ofProjectScoreCategories(projectScoreCategories: List) = - Categories(projectScoreCategories = projectScoreCategories) + fun ofProjectScoreCategories(projectScoreCategories: List) = Categories(projectScoreCategories = projectScoreCategories) fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) fun ofStrings(strings: List) = Categories(strings = strings) - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } interface Visitor { @@ -567,62 +586,49 @@ constructor( fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } 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(projectScoreCategories = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) - } - 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(projectScoreCategories = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(strings = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.projectScoreCategories != null -> - generator.writeObject(value.projectScoreCategories) - value.weighted != null -> generator.writeObject(value.weighted) - value.strings != null -> generator.writeObject(value.strings) - 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.projectScoreCategories != null -> generator.writeObject(value.projectScoreCategories) + value.weighted != null -> generator.writeObject(value.weighted) + value.strings != null -> generator.writeObject(value.strings) + 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 */ @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect - class Weighted - private constructor( - private val additionalProperties: Map, - ) { + class Weighted private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -634,25 +640,26 @@ constructor( fun validate(): Weighted = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Weighted && this.additionalProperties == other.additionalProperties + return other is Weighted && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Weighted{additionalProperties=$additionalProperties}" @@ -680,10 +687,9 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } @@ -691,10 +697,7 @@ constructor( @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class NullableVariant - private constructor( - private val additionalProperties: Map, - ) { + class NullableVariant private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -706,26 +709,26 @@ constructor( fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is NullableVariant && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" @@ -753,13 +756,11 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt index 1394924c..1b722a49 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ProjectScoreRetrieveParams -constructor( - private val projectScoreId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class ProjectScoreRetrieveParams constructor(private val projectScoreId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun projectScoreId(): String = projectScoreId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreRetrieveParams && - this.projectScoreId == other.projectScoreId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ProjectScoreRetrieveParams && + this.projectScoreId == other.projectScoreId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - projectScoreId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + projectScoreId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ProjectScoreRetrieveParams{projectScoreId=$projectScoreId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** ProjectScore id */ - fun projectScoreId(projectScoreId: String) = apply { this.projectScoreId = projectScoreId } + fun projectScoreId(projectScoreId: String) = apply { + this.projectScoreId = projectScoreId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): ProjectScoreRetrieveParams = - ProjectScoreRetrieveParams( - checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): ProjectScoreRetrieveParams = ProjectScoreRetrieveParams( + checkNotNull(projectScoreId) { + "`projectScoreId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt index a50bc70e..6f6e9c3a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParams.kt @@ -2,40 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectScoreUpdateParams constructor( + private val projectScoreId: String, + private val categories: Categories?, + private val description: String?, + private val name: String?, + private val scoreType: ScoreType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectScoreUpdateParams -constructor( - private val projectScoreId: String, - private val categories: Categories?, - private val description: String?, - private val name: String?, - private val scoreType: ScoreType?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun projectScoreId(): String = projectScoreId @@ -49,13 +59,13 @@ constructor( fun scoreType(): ScoreType? = scoreType internal fun getBody(): ProjectScoreUpdateBody { - return ProjectScoreUpdateBody( - categories, - description, - name, - scoreType, - additionalBodyProperties, - ) + return ProjectScoreUpdateBody( + categories, + description, + name, + scoreType, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -63,35 +73,39 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectScoreId - else -> "" - } + return when (index) { + 0 -> projectScoreId + else -> "" + } } @JsonDeserialize(builder = ProjectScoreUpdateBody.Builder::class) @NoAutoDetect - class ProjectScoreUpdateBody - internal constructor( - private val categories: Categories?, - private val description: String?, - private val name: String?, - private val scoreType: ScoreType?, - private val additionalProperties: Map, + class ProjectScoreUpdateBody internal constructor( + private val categories: Categories?, + private val description: String?, + private val name: String?, + private val scoreType: ScoreType?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 - @JsonProperty("categories") fun categories(): Categories? = categories + @JsonProperty("categories") + fun categories(): Categories? = categories /** Textual description of the project score */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description /** Name of the project score */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** The type of the configured score */ - @JsonProperty("score_type") fun scoreType(): ScoreType? = scoreType + @JsonProperty("score_type") + fun scoreType(): ScoreType? = scoreType @JsonAnyGetter @ExcludeMissing @@ -100,34 +114,32 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ProjectScoreUpdateBody && - this.categories == other.categories && - this.description == other.description && - this.name == other.name && - this.scoreType == other.scoreType && - this.additionalProperties == other.additionalProperties + return other is ProjectScoreUpdateBody && + this.categories == other.categories && + this.description == other.description && + this.name == other.name && + this.scoreType == other.scoreType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - categories, - description, - name, - scoreType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + categories, + description, + name, + scoreType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectScoreUpdateBody{categories=$categories, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectScoreUpdateBody{categories=$categories, description=$description, name=$name, scoreType=$scoreType, additionalProperties=$additionalProperties}" companion object { @@ -151,18 +163,27 @@ constructor( } @JsonProperty("categories") - fun categories(categories: Categories) = apply { this.categories = categories } + fun categories(categories: Categories) = apply { + this.categories = categories + } /** Textual description of the project score */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Name of the project score */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** The type of the configured score */ @JsonProperty("score_type") - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { + this.scoreType = scoreType + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -178,14 +199,13 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectScoreUpdateBody = - ProjectScoreUpdateBody( - categories, - description, - name, - scoreType, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreUpdateBody = ProjectScoreUpdateBody( + categories, + description, + name, + scoreType, + additionalProperties.toUnmodifiable(), + ) } } @@ -196,36 +216,35 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectScoreUpdateParams && - this.projectScoreId == other.projectScoreId && - this.categories == other.categories && - this.description == other.description && - this.name == other.name && - this.scoreType == other.scoreType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectScoreUpdateParams && + this.projectScoreId == other.projectScoreId && + this.categories == other.categories && + this.description == other.description && + this.name == other.name && + this.scoreType == other.scoreType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectScoreId, - categories, - description, - name, - scoreType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectScoreId, + categories, + description, + name, + scoreType, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, categories=$categories, description=$description, name=$name, scoreType=$scoreType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectScoreUpdateParams{projectScoreId=$projectScoreId, categories=$categories, description=$description, name=$name, scoreType=$scoreType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -258,10 +277,14 @@ constructor( } /** 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 { this.categories = categories } + fun categories(categories: Categories) = apply { + this.categories = categories + } /** For categorical-type project scores, the list of all categories */ fun categories(projectScoreCategories: List) = apply { @@ -284,13 +307,19 @@ constructor( } /** Textual description of the project score */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Name of the project score */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** The type of the configured score */ - fun scoreType(scoreType: ScoreType) = apply { this.scoreType = scoreType } + fun scoreType(scoreType: ScoreType) = apply { + this.scoreType = scoreType + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -330,7 +359,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -341,33 +372,33 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectScoreUpdateParams = - ProjectScoreUpdateParams( - checkNotNull(projectScoreId) { "`projectScoreId` is required but was not set" }, - categories, - description, - name, - scoreType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectScoreUpdateParams = ProjectScoreUpdateParams( + checkNotNull(projectScoreId) { + "`projectScoreId` is required but was not set" + }, + categories, + description, + name, + scoreType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Categories.Deserializer::class) @JsonSerialize(using = Categories.Serializer::class) - class Categories - private constructor( - private val projectScoreCategories: List? = null, - private val weighted: Weighted? = null, - private val strings: List? = null, - private val nullableVariant: NullableVariant? = null, - private val _json: JsonValue? = null, + class Categories private constructor( + private val projectScoreCategories: List? = null, + private val weighted: Weighted? = null, + private val strings: List? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false @@ -378,100 +409,83 @@ constructor( fun weighted(): Weighted? = weighted /** For minimum-type project scores, the list of included scores */ fun strings(): List? = strings - fun nullableVariant(): NullableVariant? = nullableVariant fun isProjectScoreCategories(): Boolean = projectScoreCategories != null - fun isWeighted(): Boolean = weighted != null - fun isStrings(): Boolean = strings != null - fun isNullableVariant(): Boolean = nullableVariant != null - fun asProjectScoreCategories(): List = - projectScoreCategories.getOrThrow("projectScoreCategories") - + fun asProjectScoreCategories(): List = projectScoreCategories.getOrThrow("projectScoreCategories") fun asWeighted(): Weighted = weighted.getOrThrow("weighted") - fun asStrings(): List = strings.getOrThrow("strings") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - projectScoreCategories != null -> - visitor.visitProjectScoreCategories(projectScoreCategories) - weighted != null -> visitor.visitWeighted(weighted) - strings != null -> visitor.visitStrings(strings) - nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) - else -> visitor.unknown(_json) - } + return when { + projectScoreCategories != null -> visitor.visitProjectScoreCategories(projectScoreCategories) + weighted != null -> visitor.visitWeighted(weighted) + strings != null -> visitor.visitStrings(strings) + nullableVariant != null -> visitor.visitNullableVariant(nullableVariant) + else -> visitor.unknown(_json) + } } fun validate(): Categories = apply { if (!validated) { - if ( - projectScoreCategories == null && - weighted == null && - strings == null && - nullableVariant == null - ) { - throw BraintrustInvalidDataException("Unknown Categories: $_json") - } - projectScoreCategories?.forEach { it.validate() } - weighted?.validate() - nullableVariant?.validate() - validated = true + if (projectScoreCategories == null && weighted == null && strings == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Categories: $_json") + } + projectScoreCategories?.forEach { it.validate() } + weighted?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Categories && - this.projectScoreCategories == other.projectScoreCategories && - this.weighted == other.weighted && - this.strings == other.strings && - this.nullableVariant == other.nullableVariant + return other is Categories && + this.projectScoreCategories == other.projectScoreCategories && + this.weighted == other.weighted && + this.strings == other.strings && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - projectScoreCategories, - weighted, - strings, - nullableVariant, - ) + return Objects.hash( + projectScoreCategories, + weighted, + strings, + nullableVariant, + ) } override fun toString(): String { - return when { - projectScoreCategories != null -> - "Categories{projectScoreCategories=$projectScoreCategories}" - weighted != null -> "Categories{weighted=$weighted}" - strings != null -> "Categories{strings=$strings}" - nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" - _json != null -> "Categories{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Categories") - } + return when { + projectScoreCategories != null -> "Categories{projectScoreCategories=$projectScoreCategories}" + weighted != null -> "Categories{weighted=$weighted}" + strings != null -> "Categories{strings=$strings}" + nullableVariant != null -> "Categories{nullableVariant=$nullableVariant}" + _json != null -> "Categories{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Categories") + } } companion object { - fun ofProjectScoreCategories(projectScoreCategories: List) = - Categories(projectScoreCategories = projectScoreCategories) + fun ofProjectScoreCategories(projectScoreCategories: List) = Categories(projectScoreCategories = projectScoreCategories) fun ofWeighted(weighted: Weighted) = Categories(weighted = weighted) fun ofStrings(strings: List) = Categories(strings = strings) - fun ofNullableVariant(nullableVariant: NullableVariant) = - Categories(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Categories(nullableVariant = nullableVariant) } interface Visitor { @@ -485,62 +499,49 @@ constructor( fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Categories: $json") + throw BraintrustInvalidDataException("Unknown Categories: $json") } } 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(projectScoreCategories = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Categories(weighted = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Categories(strings = it, _json = json) - } - 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(projectScoreCategories = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(weighted = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Categories(strings = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Categories(nullableVariant = it, _json = json) + } + + return Categories(_json = json) } } class Serializer : BaseSerializer(Categories::class) { - override fun serialize( - value: Categories, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.projectScoreCategories != null -> - generator.writeObject(value.projectScoreCategories) - value.weighted != null -> generator.writeObject(value.weighted) - value.strings != null -> generator.writeObject(value.strings) - 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.projectScoreCategories != null -> generator.writeObject(value.projectScoreCategories) + value.weighted != null -> generator.writeObject(value.weighted) + value.strings != null -> generator.writeObject(value.strings) + 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 */ @JsonDeserialize(builder = Weighted.Builder::class) @NoAutoDetect - class Weighted - private constructor( - private val additionalProperties: Map, - ) { + class Weighted private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -552,25 +553,26 @@ constructor( fun validate(): Weighted = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Weighted && this.additionalProperties == other.additionalProperties + return other is Weighted && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Weighted{additionalProperties=$additionalProperties}" @@ -598,10 +600,9 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): Weighted = Weighted(additionalProperties.toUnmodifiable()) } @@ -609,10 +610,7 @@ constructor( @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class NullableVariant - private constructor( - private val additionalProperties: Map, - ) { + class NullableVariant private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -624,26 +622,26 @@ constructor( fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is NullableVariant && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" @@ -671,31 +669,27 @@ constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } } } - class ScoreType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ScoreType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ScoreType && this.value == other.value + return other is ScoreType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -734,25 +728,23 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SLIDER -> Value.SLIDER - CATEGORICAL -> Value.CATEGORICAL - WEIGHTED -> Value.WEIGHTED - MINIMUM -> Value.MINIMUM - ONLINE -> Value.ONLINE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + SLIDER -> Value.SLIDER + CATEGORICAL -> Value.CATEGORICAL + WEIGHTED -> Value.WEIGHTED + MINIMUM -> Value.MINIMUM + ONLINE -> Value.ONLINE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - SLIDER -> Known.SLIDER - CATEGORICAL -> Known.CATEGORICAL - WEIGHTED -> Known.WEIGHTED - MINIMUM -> Known.MINIMUM - ONLINE -> Known.ONLINE - else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") - } + fun known(): Known = when (this) { + SLIDER -> Known.SLIDER + CATEGORICAL -> Known.CATEGORICAL + WEIGHTED -> Known.WEIGHTED + MINIMUM -> Known.MINIMUM + ONLINE -> Known.ONLINE + else -> throw BraintrustInvalidDataException("Unknown ScoreType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt index 3b3b10ab..cda3e786 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTag.kt @@ -2,35 +2,53 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** - * 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 */ @JsonDeserialize(builder = ProjectTag.Builder::class) @NoAutoDetect -class ProjectTag -private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val color: JsonField, - private val additionalProperties: Map, +class ProjectTag private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val userId: JsonField, + private val created: JsonField, + private val name: JsonField, + private val description: JsonField, + private val color: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -58,24 +76,38 @@ private constructor( fun color(): String? = color.getNullable("color") /** Unique identifier for the project tag */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId() = projectId - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId /** Date of project tag creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Name of the project tag */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Textual description of the project tag */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description() = description /** Color of the tag for the UI */ - @JsonProperty("color") @ExcludeMissing fun _color() = color + @JsonProperty("color") + @ExcludeMissing + fun _color() = color @JsonAnyGetter @ExcludeMissing @@ -83,54 +115,52 @@ private constructor( fun validate(): ProjectTag = apply { if (!validated) { - id() - projectId() - userId() - created() - name() - description() - color() - validated = true + id() + projectId() + userId() + created() + name() + description() + color() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTag && - this.id == other.id && - this.projectId == other.projectId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.color == other.color && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectTag && + this.id == other.id && + this.projectId == other.projectId && + this.userId == other.userId && + this.created == other.created && + this.name == other.name && + this.description == other.description && + this.color == other.color && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - projectId, - userId, - created, - name, - description, - color, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + projectId, + userId, + created, + name, + description, + color, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectTag{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectTag{id=$id, projectId=$projectId, userId=$userId, created=$created, name=$name, description=$description, color=$color, additionalProperties=$additionalProperties}" companion object { @@ -163,7 +193,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the project tag */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** Unique identifier for the project that the project tag belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -171,13 +205,17 @@ private constructor( /** Unique identifier for the project that the project tag belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } fun userId(userId: String) = userId(JsonField.of(userId)) @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } /** Date of project tag creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -185,7 +223,9 @@ private constructor( /** Date of project tag creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** Name of the project tag */ fun name(name: String) = name(JsonField.of(name)) @@ -193,7 +233,9 @@ private constructor( /** Name of the project tag */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } /** Textual description of the project tag */ fun description(description: String) = description(JsonField.of(description)) @@ -201,7 +243,9 @@ private constructor( /** Textual description of the project tag */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } /** Color of the tag for the UI */ fun color(color: String) = color(JsonField.of(color)) @@ -209,7 +253,9 @@ private constructor( /** Color of the tag for the UI */ @JsonProperty("color") @ExcludeMissing - fun color(color: JsonField) = apply { this.color = color } + fun color(color: JsonField) = apply { + this.color = color + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -225,16 +271,15 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectTag = - ProjectTag( - id, - projectId, - userId, - created, - name, - description, - color, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectTag = ProjectTag( + id, + projectId, + userId, + created, + name, + description, + color, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt index 2a58ac4a..a5b0d1bc 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagCreateParams.kt @@ -2,26 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectTagCreateParams constructor( + private val name: String, + private val projectId: String, + private val color: String?, + private val description: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectTagCreateParams -constructor( - private val name: String, - private val projectId: String, - private val color: String?, - private val description: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -33,13 +56,13 @@ constructor( fun description(): String? = description internal fun getBody(): ProjectTagCreateBody { - return ProjectTagCreateBody( - name, - projectId, - color, - description, - additionalBodyProperties, - ) + return ProjectTagCreateBody( + name, + projectId, + color, + description, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -48,28 +71,32 @@ constructor( @JsonDeserialize(builder = ProjectTagCreateBody.Builder::class) @NoAutoDetect - class ProjectTagCreateBody - internal constructor( - private val name: String?, - private val projectId: String?, - private val color: String?, - private val description: String?, - private val additionalProperties: Map, + class ProjectTagCreateBody internal constructor( + private val name: String?, + private val projectId: String?, + private val color: String?, + private val description: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the project tag */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") + fun projectId(): String? = projectId /** Color of the tag for the UI */ - @JsonProperty("color") fun color(): String? = color + @JsonProperty("color") + fun color(): String? = color /** Textual description of the project tag */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description @JsonAnyGetter @ExcludeMissing @@ -78,34 +105,32 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagCreateBody && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectTagCreateBody && + this.name == other.name && + this.projectId == other.projectId && + this.color == other.color && + this.description == other.description && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - color, - description, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + projectId, + color, + description, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectTagCreateBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" companion object { @@ -129,18 +154,28 @@ constructor( } /** Name of the project tag */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the project tag belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Color of the tag for the UI */ - @JsonProperty("color") fun color(color: String) = apply { this.color = color } + @JsonProperty("color") + fun color(color: String) = apply { + this.color = color + } /** Textual description of the project tag */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -156,14 +191,17 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectTagCreateBody = - ProjectTagCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - color, - description, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectTagCreateBody = ProjectTagCreateBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + color, + description, + additionalProperties.toUnmodifiable(), + ) } } @@ -174,34 +212,33 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagCreateParams && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectTagCreateParams && + this.name == other.name && + this.projectId == other.projectId && + this.color == other.color && + this.description == other.description && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - color, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + color, + description, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectTagCreateParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectTagCreateParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -232,16 +269,24 @@ constructor( } /** Name of the project tag */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Color of the tag for the UI */ - fun color(color: String) = apply { this.color = color } + fun color(color: String) = apply { + this.color = color + } /** Textual description of the project tag */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -281,7 +326,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -292,20 +339,22 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectTagCreateParams = - ProjectTagCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - color, - description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectTagCreateParams = ProjectTagCreateParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + color, + description, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt index 8abfb478..1c45cb0d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ProjectTagDeleteParams -constructor( - private val projectTagId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class ProjectTagDeleteParams constructor( + private val projectTagId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun projectTagId(): String = projectTagId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagDeleteParams && - this.projectTagId == other.projectTagId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectTagDeleteParams && + this.projectTagId == other.projectTagId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectTagId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectTagId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectTagDeleteParams{projectTagId=$projectTagId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } + fun projectTagId(projectTagId: String) = apply { + this.projectTagId = projectTagId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): ProjectTagDeleteParams = - ProjectTagDeleteParams( - checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectTagDeleteParams = ProjectTagDeleteParams( + checkNotNull(projectTagId) { + "`projectTagId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt index a4079295..84451554 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPage.kt @@ -2,101 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.services.blocking.ProjectTagService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class ProjectTagListPage -private constructor( - private val projectTagService: ProjectTagService, - private val params: ProjectTagListParams, - private val response: Response, -) { +class ProjectTagListPage private constructor(private val projectTagService: ProjectTagService, private val params: ProjectTagListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagListPage && - this.projectTagService == other.projectTagService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectTagListPage && + this.projectTagService == other.projectTagService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectTagService, - params, - response, - ) + return Objects.hash( + projectTagService, + params, + response, + ) } - override fun toString() = - "ProjectTagListPage{projectTagService=$projectTagService, params=$params, response=$response}" + override fun toString() = "ProjectTagListPage{projectTagService=$projectTagService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ProjectTagListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): ProjectTagListPage? { - return getNextPageParams()?.let { projectTagService.list(it) } + return getNextPageParams()?.let { + projectTagService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - projectTagService: ProjectTagService, - params: ProjectTagListParams, - response: Response - ) = - ProjectTagListPage( - projectTagService, - params, - response, - ) + fun of(projectTagService: ProjectTagService, params: ProjectTagListParams, response: Response) = ProjectTagListPage( + projectTagService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -104,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ProjectTagListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectTagListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -157,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ProjectTagListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: ProjectTagListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt index d735ff9a..23e4bf72 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListPageAsync.kt @@ -2,103 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.ProjectTagServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.ProjectTag +import com.braintrustdata.api.services.async.ProjectTagServiceAsync -class ProjectTagListPageAsync -private constructor( - private val projectTagService: ProjectTagServiceAsync, - private val params: ProjectTagListParams, - private val response: Response, -) { +class ProjectTagListPageAsync private constructor(private val projectTagService: ProjectTagServiceAsync, private val params: ProjectTagListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagListPageAsync && - this.projectTagService == other.projectTagService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ProjectTagListPageAsync && + this.projectTagService == other.projectTagService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - projectTagService, - params, - response, - ) + return Objects.hash( + projectTagService, + params, + response, + ) } - override fun toString() = - "ProjectTagListPageAsync{projectTagService=$projectTagService, params=$params, response=$response}" + override fun toString() = "ProjectTagListPageAsync{projectTagService=$projectTagService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ProjectTagListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ProjectTagListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ProjectTagListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): ProjectTagListPageAsync? { - return getNextPageParams()?.let { projectTagService.list(it) } + return getNextPageParams()?.let { + projectTagService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of( - projectTagService: ProjectTagServiceAsync, - params: ProjectTagListParams, - response: Response - ) = - ProjectTagListPageAsync( - projectTagService, - params, - response, - ) + fun of(projectTagService: ProjectTagServiceAsync, params: ProjectTagListParams, response: Response) = ProjectTagListPageAsync( + projectTagService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -106,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ProjectTagListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectTagListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -159,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ProjectTagListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: ProjectTagListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt index 82a62079..25a8ec9f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagListParams.kt @@ -2,35 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectTagListParams constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectId: String?, + private val projectName: String?, + private val projectTagName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class ProjectTagListParams -constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectId: String?, - private val projectName: String?, - private val projectTagName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun endingBefore(): String? = endingBefore @@ -50,17 +67,33 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.projectTagName?.let { params.put("project_tag_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.projectId?.let { + params.put("project_id", listOf(it.toString())) + } + this.projectName?.let { + params.put("project_name", listOf(it.toString())) + } + this.projectTagName?.let { + params.put("project_tag_name", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -70,40 +103,39 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.projectTagName == other.projectTagName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ProjectTagListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectId == other.projectId && + this.projectName == other.projectName && + this.projectTagName == other.projectTagName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectTagName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + projectTagName, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ProjectTagListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, projectTagName=$projectTagName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -142,53 +174,73 @@ 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** 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_tag to search for */ - fun projectTagName(projectTagName: String) = apply { this.projectTagName = projectTagName } + fun projectTagName(projectTagName: String) = apply { + this.projectTagName = projectTagName + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -228,84 +280,79 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): ProjectTagListParams = - ProjectTagListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - projectTagName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): ProjectTagListParams = ProjectTagListParams( + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + projectTagName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -322,38 +369,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt index a5ab8187..f656ddd3 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParams.kt @@ -2,26 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectTagReplaceParams constructor( + private val name: String, + private val projectId: String, + private val color: String?, + private val description: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectTagReplaceParams -constructor( - private val name: String, - private val projectId: String, - private val color: String?, - private val description: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -33,13 +56,13 @@ constructor( fun description(): String? = description internal fun getBody(): ProjectTagReplaceBody { - return ProjectTagReplaceBody( - name, - projectId, - color, - description, - additionalBodyProperties, - ) + return ProjectTagReplaceBody( + name, + projectId, + color, + description, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -48,28 +71,32 @@ constructor( @JsonDeserialize(builder = ProjectTagReplaceBody.Builder::class) @NoAutoDetect - class ProjectTagReplaceBody - internal constructor( - private val name: String?, - private val projectId: String?, - private val color: String?, - private val description: String?, - private val additionalProperties: Map, + class ProjectTagReplaceBody internal constructor( + private val name: String?, + private val projectId: String?, + private val color: String?, + private val description: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the project tag */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Unique identifier for the project that the project tag belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") + fun projectId(): String? = projectId /** Color of the tag for the UI */ - @JsonProperty("color") fun color(): String? = color + @JsonProperty("color") + fun color(): String? = color /** Textual description of the project tag */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description @JsonAnyGetter @ExcludeMissing @@ -78,34 +105,32 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagReplaceBody && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectTagReplaceBody && + this.name == other.name && + this.projectId == other.projectId && + this.color == other.color && + this.description == other.description && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - color, - description, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + projectId, + color, + description, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectTagReplaceBody{name=$name, projectId=$projectId, color=$color, description=$description, additionalProperties=$additionalProperties}" companion object { @@ -129,18 +154,28 @@ constructor( } /** Name of the project tag */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the project tag belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Color of the tag for the UI */ - @JsonProperty("color") fun color(color: String) = apply { this.color = color } + @JsonProperty("color") + fun color(color: String) = apply { + this.color = color + } /** Textual description of the project tag */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -156,14 +191,17 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectTagReplaceBody = - ProjectTagReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - color, - description, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectTagReplaceBody = ProjectTagReplaceBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + color, + description, + additionalProperties.toUnmodifiable(), + ) } } @@ -174,34 +212,33 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagReplaceParams && - this.name == other.name && - this.projectId == other.projectId && - this.color == other.color && - this.description == other.description && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectTagReplaceParams && + this.name == other.name && + this.projectId == other.projectId && + this.color == other.color && + this.description == other.description && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - color, - description, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + color, + description, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectTagReplaceParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectTagReplaceParams{name=$name, projectId=$projectId, color=$color, description=$description, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -232,16 +269,24 @@ constructor( } /** Name of the project tag */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the project tag belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Color of the tag for the UI */ - fun color(color: String) = apply { this.color = color } + fun color(color: String) = apply { + this.color = color + } /** Textual description of the project tag */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -281,7 +326,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -292,20 +339,22 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectTagReplaceParams = - ProjectTagReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - color, - description, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectTagReplaceParams = ProjectTagReplaceParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + color, + description, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt index f0e6a318..15f10f1a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class ProjectTagRetrieveParams -constructor( - private val projectTagId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class ProjectTagRetrieveParams constructor(private val projectTagId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun projectTagId(): String = projectTagId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagRetrieveParams && - this.projectTagId == other.projectTagId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ProjectTagRetrieveParams && + this.projectTagId == other.projectTagId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - projectTagId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + projectTagId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ProjectTagRetrieveParams{projectTagId=$projectTagId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** ProjectTag id */ - fun projectTagId(projectTagId: String) = apply { this.projectTagId = projectTagId } + fun projectTagId(projectTagId: String) = apply { + this.projectTagId = projectTagId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): ProjectTagRetrieveParams = - ProjectTagRetrieveParams( - checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): ProjectTagRetrieveParams = ProjectTagRetrieveParams( + checkNotNull(projectTagId) { + "`projectTagId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt index 76d6d12a..8b409cb8 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParams.kt @@ -2,26 +2,49 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectTagUpdateParams constructor( + private val projectTagId: String, + private val color: String?, + private val description: String?, + private val name: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectTagUpdateParams -constructor( - private val projectTagId: String, - private val color: String?, - private val description: String?, - private val name: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun projectTagId(): String = projectTagId @@ -33,12 +56,12 @@ constructor( fun name(): String? = name internal fun getBody(): ProjectTagUpdateBody { - return ProjectTagUpdateBody( - color, - description, - name, - additionalBodyProperties, - ) + return ProjectTagUpdateBody( + color, + description, + name, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -46,32 +69,35 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectTagId - else -> "" - } + return when (index) { + 0 -> projectTagId + else -> "" + } } @JsonDeserialize(builder = ProjectTagUpdateBody.Builder::class) @NoAutoDetect - class ProjectTagUpdateBody - internal constructor( - private val color: String?, - private val description: String?, - private val name: String?, - private val additionalProperties: Map, + class ProjectTagUpdateBody internal constructor( + private val color: String?, + private val description: String?, + private val name: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Color of the tag for the UI */ - @JsonProperty("color") fun color(): String? = color + @JsonProperty("color") + fun color(): String? = color /** Textual description of the project tag */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description /** Name of the project tag */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name @JsonAnyGetter @ExcludeMissing @@ -80,32 +106,30 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagUpdateBody && - this.color == other.color && - this.description == other.description && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectTagUpdateBody && + this.color == other.color && + this.description == other.description && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - color, - description, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + color, + description, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectTagUpdateBody{color=$color, description=$description, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -127,14 +151,22 @@ constructor( } /** Color of the tag for the UI */ - @JsonProperty("color") fun color(color: String) = apply { this.color = color } + @JsonProperty("color") + fun color(color: String) = apply { + this.color = color + } /** Textual description of the project tag */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Name of the project tag */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -150,13 +182,12 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectTagUpdateBody = - ProjectTagUpdateBody( - color, - description, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectTagUpdateBody = ProjectTagUpdateBody( + color, + description, + name, + additionalProperties.toUnmodifiable(), + ) } } @@ -167,34 +198,33 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectTagUpdateParams && - this.projectTagId == other.projectTagId && - this.color == other.color && - this.description == other.description && - this.name == other.name && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectTagUpdateParams && + this.projectTagId == other.projectTagId && + this.color == other.color && + this.description == other.description && + this.name == other.name && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectTagId, - color, - description, - name, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectTagId, + color, + description, + name, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectTagUpdateParams{projectTagId=$projectTagId, color=$color, description=$description, name=$name, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectTagUpdateParams{projectTagId=$projectTagId, color=$color, description=$description, name=$name, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -225,16 +255,24 @@ constructor( } /** 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 { this.color = color } + fun color(color: String) = apply { + this.color = color + } /** Textual description of the project tag */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Name of the project tag */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -274,7 +312,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -285,20 +325,20 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectTagUpdateParams = - ProjectTagUpdateParams( - checkNotNull(projectTagId) { "`projectTagId` is required but was not set" }, - color, - description, - name, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectTagUpdateParams = ProjectTagUpdateParams( + checkNotNull(projectTagId) { + "`projectTagId` is required but was not set" + }, + color, + description, + name, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt index e959182c..ab8d83d8 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ProjectUpdateParams.kt @@ -2,25 +2,48 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ProjectUpdateParams constructor( + private val projectId: String, + private val name: String?, + private val settings: Settings?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ProjectUpdateParams -constructor( - private val projectId: String, - private val name: String?, - private val settings: Settings?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun projectId(): String = projectId @@ -30,11 +53,11 @@ constructor( fun settings(): Settings? = settings internal fun getBody(): ProjectUpdateBody { - return ProjectUpdateBody( - name, - settings, - additionalBodyProperties, - ) + return ProjectUpdateBody( + name, + settings, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -42,31 +65,28 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } + return when (index) { + 0 -> projectId + else -> "" + } } @JsonDeserialize(builder = ProjectUpdateBody.Builder::class) @NoAutoDetect - class ProjectUpdateBody - internal constructor( - private val name: String?, - private val settings: Settings?, - private val additionalProperties: Map, - ) { + class ProjectUpdateBody internal constructor(private val name: String?, private val settings: Settings?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** Name of the project */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = 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") fun settings(): Settings? = settings + @JsonProperty("settings") + fun settings(): Settings? = settings @JsonAnyGetter @ExcludeMissing @@ -75,30 +95,28 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectUpdateBody && - this.name == other.name && - this.settings == other.settings && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ProjectUpdateBody && + this.name == other.name && + this.settings == other.settings && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - settings, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + settings, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" + override fun toString() = "ProjectUpdateBody{name=$name, settings=$settings, additionalProperties=$additionalProperties}" companion object { @@ -118,14 +136,19 @@ constructor( } /** Name of the project */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = 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. */ @JsonProperty("settings") - fun settings(settings: Settings) = apply { this.settings = settings } + fun settings(settings: Settings) = apply { + this.settings = settings + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -141,12 +164,11 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ProjectUpdateBody = - ProjectUpdateBody( - name, - settings, - additionalProperties.toUnmodifiable(), - ) + fun build(): ProjectUpdateBody = ProjectUpdateBody( + name, + settings, + additionalProperties.toUnmodifiable(), + ) } } @@ -157,32 +179,31 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProjectUpdateParams && - this.projectId == other.projectId && - this.name == other.name && - this.settings == other.settings && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ProjectUpdateParams && + this.projectId == other.projectId && + this.name == other.name && + this.settings == other.settings && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - projectId, - name, - settings, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + projectId, + name, + settings, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ProjectUpdateParams{projectId=$projectId, name=$name, settings=$settings, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ProjectUpdateParams{projectId=$projectId, name=$name, settings=$settings, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -211,16 +232,22 @@ constructor( } /** 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 { this.name = name } + fun name(name: String) = 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: Settings) = apply { this.settings = settings } + fun settings(settings: Settings) = apply { + this.settings = settings + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -260,7 +287,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -271,38 +300,35 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ProjectUpdateParams = - ProjectUpdateParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - name, - settings, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ProjectUpdateParams = ProjectUpdateParams( + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + name, + settings, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } /** - * 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. */ @JsonDeserialize(builder = Settings.Builder::class) @NoAutoDetect - class Settings - private constructor( - private val comparisonKey: String?, - private val additionalProperties: Map, - ) { + class Settings private constructor(private val comparisonKey: String?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** The key used to join two experiments (defaults to `input`). */ - @JsonProperty("comparison_key") fun comparisonKey(): String? = comparisonKey + @JsonProperty("comparison_key") + fun comparisonKey(): String? = comparisonKey @JsonAnyGetter @ExcludeMissing @@ -311,24 +337,23 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Settings && - this.comparisonKey == other.comparisonKey && - this.additionalProperties == other.additionalProperties + return other is Settings && + this.comparisonKey == other.comparisonKey && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(comparisonKey, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(comparisonKey, additionalProperties) + } + return hashCode } - override fun toString() = - "Settings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" + override fun toString() = "Settings{comparisonKey=$comparisonKey, additionalProperties=$additionalProperties}" companion object { @@ -347,7 +372,9 @@ constructor( /** The key used to join two experiments (defaults to `input`). */ @JsonProperty("comparison_key") - fun comparisonKey(comparisonKey: String) = apply { this.comparisonKey = comparisonKey } + fun comparisonKey(comparisonKey: String) = apply { + this.comparisonKey = comparisonKey + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt index 53d7e1b6..de375cda 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Prompt.kt @@ -2,40 +2,55 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = Prompt.Builder::class) @NoAutoDetect -class Prompt -private constructor( - private val id: JsonField, - private val _xactId: JsonField, - private val projectId: JsonField, - private val logId: JsonField, - private val orgId: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val description: JsonField, - private val created: JsonField, - private val promptData: JsonField, - private val tags: JsonField>, - private val metadata: JsonField, - private val functionType: JsonField, - private val additionalProperties: Map, +class Prompt private constructor( + private val id: JsonField, + private val _xactId: JsonField, + private val projectId: JsonField, + private val logId: JsonField, + private val orgId: JsonField, + private val name: JsonField, + private val slug: JsonField, + private val description: JsonField, + private val created: JsonField, + private val promptData: JsonField, + private val tags: JsonField>, + private val metadata: JsonField, + private val functionType: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -46,9 +61,10 @@ private constructor( 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") @@ -85,46 +101,73 @@ private constructor( fun functionType(): FunctionType? = functionType.getNullable("function_type") /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _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) */ - @JsonProperty("_xact_id") @ExcludeMissing fun __xactId() = _xactId + @JsonProperty("_xact_id") + @ExcludeMissing + fun __xactId() = _xactId /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId() = projectId /** A literal 'p' which identifies the object as a project prompt */ - @JsonProperty("log_id") @ExcludeMissing fun _logId() = logId + @JsonProperty("log_id") + @ExcludeMissing + fun _logId() = logId /** Unique identifier for the organization */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId() = orgId /** Name of the prompt */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Unique identifier for the prompt */ - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug + @JsonProperty("slug") + @ExcludeMissing + fun _slug() = slug /** Textual description of the prompt */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description() = description /** Date of prompt creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") @ExcludeMissing fun _promptData() = promptData + @JsonProperty("prompt_data") + @ExcludeMissing + fun _promptData() = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") @ExcludeMissing fun _tags() = tags + @JsonProperty("tags") + @ExcludeMissing + fun _tags() = tags /** User-controlled metadata about the prompt */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata() = metadata - @JsonProperty("function_type") @ExcludeMissing fun _functionType() = functionType + @JsonProperty("function_type") + @ExcludeMissing + fun _functionType() = functionType @JsonAnyGetter @ExcludeMissing @@ -132,72 +175,70 @@ private constructor( fun validate(): Prompt = apply { if (!validated) { - id() - _xactId() - projectId() - logId() - orgId() - name() - slug() - description() - created() - promptData()?.validate() - tags() - metadata()?.validate() - functionType() - validated = true + id() + _xactId() + projectId() + logId() + orgId() + name() + slug() + description() + created() + promptData()?.validate() + tags() + metadata()?.validate() + functionType() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.id == other.id && - this._xactId == other._xactId && - this.projectId == other.projectId && - this.logId == other.logId && - this.orgId == other.orgId && - this.name == other.name && - this.slug == other.slug && - this.description == other.description && - this.created == other.created && - this.promptData == other.promptData && - this.tags == other.tags && - this.metadata == other.metadata && - this.functionType == other.functionType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Prompt && + this.id == other.id && + this._xactId == other._xactId && + this.projectId == other.projectId && + this.logId == other.logId && + this.orgId == other.orgId && + this.name == other.name && + this.slug == other.slug && + this.description == other.description && + this.created == other.created && + this.promptData == other.promptData && + this.tags == other.tags && + this.metadata == other.metadata && + this.functionType == other.functionType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags, - metadata, - functionType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + _xactId, + projectId, + logId, + orgId, + name, + slug, + description, + created, + promptData, + tags, + metadata, + functionType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Prompt{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, additionalProperties=$additionalProperties}" + override fun toString() = "Prompt{id=$id, _xactId=$_xactId, projectId=$projectId, logId=$logId, orgId=$orgId, name=$name, slug=$slug, description=$description, created=$created, promptData=$promptData, tags=$tags, metadata=$metadata, functionType=$functionType, additionalProperties=$additionalProperties}" companion object { @@ -242,23 +283,31 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the prompt */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + 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) */ @JsonProperty("_xact_id") @ExcludeMissing - fun _xactId(_xactId: JsonField) = apply { this._xactId = _xactId } + fun _xactId(_xactId: JsonField) = apply { + this._xactId = _xactId + } /** Unique identifier for the project that the prompt belongs under */ fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @@ -266,7 +315,9 @@ private constructor( /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } /** A literal 'p' which identifies the object as a project prompt */ fun logId(logId: LogId) = logId(JsonField.of(logId)) @@ -274,7 +325,9 @@ private constructor( /** A literal 'p' which identifies the object as a project prompt */ @JsonProperty("log_id") @ExcludeMissing - fun logId(logId: JsonField) = apply { this.logId = logId } + fun logId(logId: JsonField) = apply { + this.logId = logId + } /** Unique identifier for the organization */ fun orgId(orgId: String) = orgId(JsonField.of(orgId)) @@ -282,7 +335,9 @@ private constructor( /** Unique identifier for the organization */ @JsonProperty("org_id") @ExcludeMissing - fun orgId(orgId: JsonField) = apply { this.orgId = orgId } + fun orgId(orgId: JsonField) = apply { + this.orgId = orgId + } /** Name of the prompt */ fun name(name: String) = name(JsonField.of(name)) @@ -290,7 +345,9 @@ private constructor( /** Name of the prompt */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } /** Unique identifier for the prompt */ fun slug(slug: String) = slug(JsonField.of(slug)) @@ -298,7 +355,9 @@ private constructor( /** Unique identifier for the prompt */ @JsonProperty("slug") @ExcludeMissing - 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.of(description)) @@ -306,7 +365,9 @@ private constructor( /** Textual description of the prompt */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } /** Date of prompt creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -314,7 +375,9 @@ private constructor( /** Date of prompt creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** The prompt, model, and its parameters */ fun promptData(promptData: PromptData) = promptData(JsonField.of(promptData)) @@ -322,7 +385,9 @@ private constructor( /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") @ExcludeMissing - 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.of(tags)) @@ -330,7 +395,9 @@ private constructor( /** A list of tags for the prompt */ @JsonProperty("tags") @ExcludeMissing - fun tags(tags: JsonField>) = apply { this.tags = tags } + fun tags(tags: JsonField>) = apply { + this.tags = tags + } /** User-controlled metadata about the prompt */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) @@ -338,7 +405,9 @@ private constructor( /** User-controlled metadata about the prompt */ @JsonProperty("metadata") @ExcludeMissing - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } fun functionType(functionType: FunctionType) = functionType(JsonField.of(functionType)) @@ -362,39 +431,36 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Prompt = - Prompt( - id, - _xactId, - projectId, - logId, - orgId, - name, - slug, - description, - created, - promptData, - tags.map { it.toUnmodifiable() }, - metadata, - functionType, - additionalProperties.toUnmodifiable(), - ) + fun build(): Prompt = Prompt( + id, + _xactId, + projectId, + logId, + orgId, + name, + slug, + description, + created, + promptData, + tags.map { it.toUnmodifiable() }, + metadata, + functionType, + additionalProperties.toUnmodifiable(), + ) } - class LogId - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class LogId @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is LogId && this.value == other.value + return other is LogId && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -417,35 +483,31 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - P -> Value.P - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + P -> Value.P + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - P -> Known.P - else -> throw BraintrustInvalidDataException("Unknown LogId: $value") - } + fun known(): Known = when (this) { + P -> Known.P + else -> throw BraintrustInvalidDataException("Unknown LogId: $value") + } fun asString(): String = _value().asStringOrThrow() } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionType && this.value == other.value + return other is FunctionType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -476,21 +538,19 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TASK -> Value.TASK - LLM -> Value.LLM - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + TASK -> Value.TASK + LLM -> Value.LLM + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - TASK -> Known.TASK - LLM -> Known.LLM - SCORER -> Known.SCORER - else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") - } + fun known(): Known = when (this) { + TASK -> Known.TASK + LLM -> Known.LLM + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -498,10 +558,7 @@ private constructor( /** User-controlled metadata about the prompt */ @JsonDeserialize(builder = Metadata.Builder::class) @NoAutoDetect - class Metadata - private constructor( - private val additionalProperties: Map, - ) { + class Metadata private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -513,25 +570,26 @@ private constructor( fun validate(): Metadata = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metadata && this.additionalProperties == other.additionalProperties + return other is Metadata && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metadata{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt index 258981de..dc35202e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptCreateParams.kt @@ -2,33 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class PromptCreateParams constructor( + private val name: String, + private val projectId: String, + private val slug: String, + private val description: String?, + private val functionType: FunctionType?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class PromptCreateParams -constructor( - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val functionType: FunctionType?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -46,16 +65,16 @@ constructor( fun tags(): List? = tags internal fun getBody(): PromptCreateBody { - return PromptCreateBody( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalBodyProperties, - ) + return PromptCreateBody( + name, + projectId, + slug, + description, + functionType, + promptData, + tags, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -64,39 +83,46 @@ constructor( @JsonDeserialize(builder = PromptCreateBody.Builder::class) @NoAutoDetect - class PromptCreateBody - internal constructor( - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val functionType: FunctionType?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, + class PromptCreateBody internal constructor( + private val name: String?, + private val projectId: String?, + private val slug: String?, + private val description: String?, + private val functionType: FunctionType?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") + fun projectId(): String? = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(): String? = slug + @JsonProperty("slug") + fun slug(): String? = slug /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description - @JsonProperty("function_type") fun functionType(): FunctionType? = functionType + @JsonProperty("function_type") + fun functionType(): FunctionType? = functionType /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") + fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -105,40 +131,38 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptCreateBody && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptCreateBody && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.functionType == other.functionType && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + projectId, + slug, + description, + functionType, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "PromptCreateBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { @@ -168,18 +192,28 @@ constructor( } /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } + @JsonProperty("slug") + fun slug(slug: String) = apply { + this.slug = slug + } /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } @JsonProperty("function_type") fun functionType(functionType: FunctionType) = apply { @@ -188,10 +222,15 @@ constructor( /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + @JsonProperty("tags") + fun tags(tags: List) = apply { + this.tags = tags + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -207,17 +246,22 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptCreateBody = - PromptCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionType, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptCreateBody = PromptCreateBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + checkNotNull(slug) { + "`slug` is required but was not set" + }, + description, + functionType, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -228,40 +272,39 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptCreateParams && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is PromptCreateParams && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.functionType == other.functionType && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + slug, + description, + functionType, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "PromptCreateParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "PromptCreateParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -298,21 +341,33 @@ constructor( } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: String) = apply { + this.slug = slug + } /** Textual description of the prompt */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } - fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } + fun functionType(functionType: FunctionType) = apply { + this.functionType = functionType + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -321,7 +376,9 @@ constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun addTag(tag: String) = apply { + this.tags.add(tag) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -361,7 +418,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -372,40 +431,42 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): PromptCreateParams = - PromptCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionType, - promptData, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): PromptCreateParams = PromptCreateParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + checkNotNull(slug) { + "`slug` is required but was not set" + }, + description, + functionType, + promptData, + if(tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionType && this.value == other.value + return other is FunctionType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -436,21 +497,19 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TASK -> Value.TASK - LLM -> Value.LLM - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + TASK -> Value.TASK + LLM -> Value.LLM + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - TASK -> Known.TASK - LLM -> Known.LLM - SCORER -> Known.SCORER - else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") - } + fun known(): Known = when (this) { + TASK -> Known.TASK + LLM -> Known.LLM + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt index 4258a742..56079f7d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptData.kt @@ -2,40 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** The prompt, model, and its parameters */ @JsonDeserialize(builder = PromptData.Builder::class) @NoAutoDetect -class PromptData -private constructor( - private val prompt: JsonField, - private val options: JsonField, - private val parser: JsonField, - private val origin: JsonField, - private val additionalProperties: Map, +class PromptData private constructor( + private val prompt: JsonField, + private val options: JsonField, + private val parser: JsonField, + private val origin: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -50,13 +57,21 @@ private constructor( fun origin(): Origin? = origin.getNullable("origin") - @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt + @JsonProperty("prompt") + @ExcludeMissing + fun _prompt() = prompt - @JsonProperty("options") @ExcludeMissing fun _options() = options + @JsonProperty("options") + @ExcludeMissing + fun _options() = options - @JsonProperty("parser") @ExcludeMissing fun _parser() = parser + @JsonProperty("parser") + @ExcludeMissing + fun _parser() = parser - @JsonProperty("origin") @ExcludeMissing fun _origin() = origin + @JsonProperty("origin") + @ExcludeMissing + fun _origin() = origin @JsonAnyGetter @ExcludeMissing @@ -64,45 +79,43 @@ private constructor( fun validate(): PromptData = apply { if (!validated) { - prompt() - options()?.validate() - parser()?.validate() - origin()?.validate() - validated = true + prompt() + options()?.validate() + parser()?.validate() + origin()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptData && - this.prompt == other.prompt && - this.options == other.options && - this.parser == other.parser && - this.origin == other.origin && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptData && + this.prompt == other.prompt && + this.options == other.options && + this.parser == other.parser && + this.origin == other.origin && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - prompt, - options, - parser, - origin, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + prompt, + options, + parser, + origin, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "PromptData{prompt=$prompt, options=$options, parser=$parser, origin=$origin, additionalProperties=$additionalProperties}" + override fun toString() = "PromptData{prompt=$prompt, options=$options, parser=$parser, origin=$origin, additionalProperties=$additionalProperties}" companion object { @@ -129,25 +142,33 @@ private constructor( @JsonProperty("prompt") @ExcludeMissing - fun prompt(prompt: JsonField) = apply { this.prompt = prompt } + fun prompt(prompt: JsonField) = apply { + this.prompt = prompt + } fun options(options: Options) = options(JsonField.of(options)) @JsonProperty("options") @ExcludeMissing - fun options(options: JsonField) = apply { this.options = options } + fun options(options: JsonField) = apply { + this.options = options + } fun parser(parser: Parser) = parser(JsonField.of(parser)) @JsonProperty("parser") @ExcludeMissing - fun parser(parser: JsonField) = apply { this.parser = parser } + fun parser(parser: JsonField) = apply { + this.parser = parser + } fun origin(origin: Origin) = origin(JsonField.of(origin)) @JsonProperty("origin") @ExcludeMissing - fun origin(origin: JsonField) = apply { this.origin = origin } + fun origin(origin: JsonField) = apply { + this.origin = origin + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -163,24 +184,23 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptData = - PromptData( - prompt, - options, - parser, - origin, - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptData = PromptData( + prompt, + options, + parser, + origin, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Options.Builder::class) @NoAutoDetect - class Options - private constructor( - private val model: JsonField, - private val params: JsonField, - private val position: JsonField, - private val additionalProperties: Map, + class Options private constructor( + private val model: JsonField, + private val params: JsonField, + private val position: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -193,11 +213,17 @@ private constructor( fun position(): String? = position.getNullable("position") - @JsonProperty("model") @ExcludeMissing fun _model() = model + @JsonProperty("model") + @ExcludeMissing + fun _model() = model - @JsonProperty("params") @ExcludeMissing fun _params() = params + @JsonProperty("params") + @ExcludeMissing + fun _params() = params - @JsonProperty("position") @ExcludeMissing fun _position() = position + @JsonProperty("position") + @ExcludeMissing + fun _position() = position @JsonAnyGetter @ExcludeMissing @@ -205,42 +231,40 @@ private constructor( fun validate(): Options = apply { if (!validated) { - model() - params() - position() - validated = true + model() + params() + position() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Options && - this.model == other.model && - this.params == other.params && - this.position == other.position && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Options && + this.model == other.model && + this.params == other.params && + this.position == other.position && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - model, - params, - position, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + model, + params, + position, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" + override fun toString() = "Options{model=$model, params=$params, position=$position, additionalProperties=$additionalProperties}" companion object { @@ -265,19 +289,25 @@ private constructor( @JsonProperty("model") @ExcludeMissing - fun model(model: JsonField) = apply { this.model = model } + fun model(model: JsonField) = apply { + this.model = model + } fun params(params: Params) = params(JsonField.of(params)) @JsonProperty("params") @ExcludeMissing - fun params(params: JsonField) = apply { this.params = params } + fun params(params: JsonField) = apply { + this.params = params + } fun position(position: String) = position(JsonField.of(position)) @JsonProperty("position") @ExcludeMissing - fun position(position: JsonField) = apply { this.position = position } + fun position(position: JsonField) = apply { + this.position = position + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -293,153 +323,119 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Options = - Options( - model, - params, - position, - additionalProperties.toUnmodifiable(), - ) + fun build(): Options = Options( + model, + params, + position, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Params.Deserializer::class) @JsonSerialize(using = Params.Serializer::class) - class Params - private constructor( - private val openaiModelParams: OpenAIModelParams? = null, - private val anthropicModelParams: AnthropicModelParams? = null, - private val googleModelParams: GoogleModelParams? = null, - private val windowAiModelParams: WindowAiModelParams? = null, - private val jsCompletionParams: JsCompletionParams? = null, - private val _json: JsonValue? = null, + class Params private constructor( + private val openaiModelParams: OpenAIModelParams? = null, + private val anthropicModelParams: AnthropicModelParams? = null, + private val googleModelParams: GoogleModelParams? = null, + private val windowAiModelParams: WindowAiModelParams? = null, + private val jsCompletionParams: JsCompletionParams? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun openaiModelParams(): OpenAIModelParams? = openaiModelParams - fun anthropicModelParams(): AnthropicModelParams? = anthropicModelParams - fun googleModelParams(): GoogleModelParams? = googleModelParams - fun windowAiModelParams(): WindowAiModelParams? = windowAiModelParams - fun jsCompletionParams(): JsCompletionParams? = jsCompletionParams fun isOpenAIModelParams(): Boolean = openaiModelParams != null - fun isAnthropicModelParams(): Boolean = anthropicModelParams != null - fun isGoogleModelParams(): Boolean = googleModelParams != null - fun isWindowAiModelParams(): Boolean = windowAiModelParams != null - fun isJsCompletionParams(): Boolean = jsCompletionParams != null - fun asOpenAIModelParams(): OpenAIModelParams = - openaiModelParams.getOrThrow("openaiModelParams") - - fun asAnthropicModelParams(): AnthropicModelParams = - anthropicModelParams.getOrThrow("anthropicModelParams") - - fun asGoogleModelParams(): GoogleModelParams = - googleModelParams.getOrThrow("googleModelParams") - - fun asWindowAiModelParams(): WindowAiModelParams = - windowAiModelParams.getOrThrow("windowAiModelParams") - - fun asJsCompletionParams(): JsCompletionParams = - jsCompletionParams.getOrThrow("jsCompletionParams") + fun asOpenAIModelParams(): OpenAIModelParams = openaiModelParams.getOrThrow("openaiModelParams") + fun asAnthropicModelParams(): AnthropicModelParams = anthropicModelParams.getOrThrow("anthropicModelParams") + fun asGoogleModelParams(): GoogleModelParams = googleModelParams.getOrThrow("googleModelParams") + fun asWindowAiModelParams(): WindowAiModelParams = windowAiModelParams.getOrThrow("windowAiModelParams") + fun asJsCompletionParams(): JsCompletionParams = jsCompletionParams.getOrThrow("jsCompletionParams") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - openaiModelParams != null -> visitor.visitOpenAIModelParams(openaiModelParams) - anthropicModelParams != null -> - visitor.visitAnthropicModelParams(anthropicModelParams) - googleModelParams != null -> visitor.visitGoogleModelParams(googleModelParams) - windowAiModelParams != null -> - visitor.visitWindowAiModelParams(windowAiModelParams) - jsCompletionParams != null -> - visitor.visitJsCompletionParams(jsCompletionParams) - else -> visitor.unknown(_json) - } + return when { + openaiModelParams != null -> visitor.visitOpenAIModelParams(openaiModelParams) + anthropicModelParams != null -> visitor.visitAnthropicModelParams(anthropicModelParams) + googleModelParams != null -> visitor.visitGoogleModelParams(googleModelParams) + windowAiModelParams != null -> visitor.visitWindowAiModelParams(windowAiModelParams) + jsCompletionParams != null -> visitor.visitJsCompletionParams(jsCompletionParams) + else -> visitor.unknown(_json) + } } fun validate(): Params = apply { if (!validated) { - if ( - openaiModelParams == null && - anthropicModelParams == null && - googleModelParams == null && - windowAiModelParams == null && - jsCompletionParams == null - ) { - throw BraintrustInvalidDataException("Unknown Params: $_json") - } - openaiModelParams?.validate() - anthropicModelParams?.validate() - googleModelParams?.validate() - windowAiModelParams?.validate() - jsCompletionParams?.validate() - validated = true + if (openaiModelParams == null && anthropicModelParams == null && googleModelParams == null && windowAiModelParams == null && jsCompletionParams == null) { + throw BraintrustInvalidDataException("Unknown Params: $_json") + } + openaiModelParams?.validate() + anthropicModelParams?.validate() + googleModelParams?.validate() + windowAiModelParams?.validate() + jsCompletionParams?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - this.openaiModelParams == other.openaiModelParams && - this.anthropicModelParams == other.anthropicModelParams && - this.googleModelParams == other.googleModelParams && - this.windowAiModelParams == other.windowAiModelParams && - this.jsCompletionParams == other.jsCompletionParams + if (this === other) { + return true + } + + return other is Params && + this.openaiModelParams == other.openaiModelParams && + this.anthropicModelParams == other.anthropicModelParams && + this.googleModelParams == other.googleModelParams && + this.windowAiModelParams == other.windowAiModelParams && + this.jsCompletionParams == other.jsCompletionParams } override fun hashCode(): Int { - return Objects.hash( - openaiModelParams, - anthropicModelParams, - googleModelParams, - windowAiModelParams, - jsCompletionParams, - ) + return Objects.hash( + openaiModelParams, + anthropicModelParams, + googleModelParams, + windowAiModelParams, + jsCompletionParams, + ) } override fun toString(): String { - return when { - openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" - anthropicModelParams != null -> - "Params{anthropicModelParams=$anthropicModelParams}" - googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" - windowAiModelParams != null -> - "Params{windowAiModelParams=$windowAiModelParams}" - jsCompletionParams != null -> "Params{jsCompletionParams=$jsCompletionParams}" - _json != null -> "Params{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Params") - } + return when { + openaiModelParams != null -> "Params{openaiModelParams=$openaiModelParams}" + anthropicModelParams != null -> "Params{anthropicModelParams=$anthropicModelParams}" + googleModelParams != null -> "Params{googleModelParams=$googleModelParams}" + windowAiModelParams != null -> "Params{windowAiModelParams=$windowAiModelParams}" + jsCompletionParams != null -> "Params{jsCompletionParams=$jsCompletionParams}" + _json != null -> "Params{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Params") + } } companion object { - fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = - Params(openaiModelParams = openaiModelParams) + fun ofOpenAIModelParams(openaiModelParams: OpenAIModelParams) = Params(openaiModelParams = openaiModelParams) - fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = - Params(anthropicModelParams = anthropicModelParams) + fun ofAnthropicModelParams(anthropicModelParams: AnthropicModelParams) = Params(anthropicModelParams = anthropicModelParams) - fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = - Params(googleModelParams = googleModelParams) + fun ofGoogleModelParams(googleModelParams: GoogleModelParams) = Params(googleModelParams = googleModelParams) - fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = - Params(windowAiModelParams = windowAiModelParams) + fun ofWindowAiModelParams(windowAiModelParams: WindowAiModelParams) = Params(windowAiModelParams = windowAiModelParams) - fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = - Params(jsCompletionParams = jsCompletionParams) + fun ofJsCompletionParams(jsCompletionParams: JsCompletionParams) = Params(jsCompletionParams = jsCompletionParams) } interface Visitor { @@ -455,79 +451,65 @@ private constructor( fun visitJsCompletionParams(jsCompletionParams: JsCompletionParams): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Params: $json") + throw BraintrustInvalidDataException("Unknown Params: $json") } } class Deserializer : BaseDeserializer(Params::class) { override fun ObjectCodec.deserialize(node: JsonNode): Params { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(openaiModelParams = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(anthropicModelParams = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(googleModelParams = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(windowAiModelParams = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Params(jsCompletionParams = it, _json = json) - } - - return Params(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(openaiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(anthropicModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(googleModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(windowAiModelParams = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Params(jsCompletionParams = it, _json = json) + } + + return Params(_json = json) } } class Serializer : BaseSerializer(Params::class) { - override fun serialize( - value: Params, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.openaiModelParams != null -> - generator.writeObject(value.openaiModelParams) - value.anthropicModelParams != null -> - generator.writeObject(value.anthropicModelParams) - value.googleModelParams != null -> - generator.writeObject(value.googleModelParams) - value.windowAiModelParams != null -> - generator.writeObject(value.windowAiModelParams) - value.jsCompletionParams != null -> - generator.writeObject(value.jsCompletionParams) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Params") - } + override fun serialize(value: Params, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.openaiModelParams != null -> generator.writeObject(value.openaiModelParams) + value.anthropicModelParams != null -> generator.writeObject(value.anthropicModelParams) + value.googleModelParams != null -> generator.writeObject(value.googleModelParams) + value.windowAiModelParams != null -> generator.writeObject(value.windowAiModelParams) + value.jsCompletionParams != null -> generator.writeObject(value.jsCompletionParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Params") + } } } @JsonDeserialize(builder = OpenAIModelParams.Builder::class) @NoAutoDetect - class OpenAIModelParams - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val maxTokens: JsonField, - private val frequencyPenalty: JsonField, - private val presencePenalty: JsonField, - private val responseFormat: JsonField, - private val toolChoice: JsonField, - private val functionCall: JsonField, - private val n: JsonField, - private val stop: JsonField>, - private val additionalProperties: Map, + class OpenAIModelParams private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val maxTokens: JsonField, + private val frequencyPenalty: JsonField, + private val presencePenalty: JsonField, + private val responseFormat: JsonField, + private val toolChoice: JsonField, + private val functionCall: JsonField, + private val n: JsonField, + private val stop: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -546,8 +528,7 @@ private constructor( fun presencePenalty(): Double? = presencePenalty.getNullable("presence_penalty") - fun responseFormat(): ResponseFormat? = - responseFormat.getNullable("response_format") + fun responseFormat(): ResponseFormat? = responseFormat.getNullable("response_format") fun toolChoice(): ToolChoice? = toolChoice.getNullable("tool_choice") @@ -557,13 +538,21 @@ private constructor( fun stop(): List? = stop.getNullable("stop") - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + @JsonProperty("use_cache") + @ExcludeMissing + fun _useCache() = useCache - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature() = temperature - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP + @JsonProperty("top_p") + @ExcludeMissing + fun _topP() = topP - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") + @ExcludeMissing + fun _maxTokens() = maxTokens @JsonProperty("frequency_penalty") @ExcludeMissing @@ -577,13 +566,21 @@ private constructor( @ExcludeMissing fun _responseFormat() = responseFormat - @JsonProperty("tool_choice") @ExcludeMissing fun _toolChoice() = toolChoice + @JsonProperty("tool_choice") + @ExcludeMissing + fun _toolChoice() = toolChoice - @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall + @JsonProperty("function_call") + @ExcludeMissing + fun _functionCall() = functionCall - @JsonProperty("n") @ExcludeMissing fun _n() = n + @JsonProperty("n") + @ExcludeMissing + fun _n() = n - @JsonProperty("stop") @ExcludeMissing fun _stop() = stop + @JsonProperty("stop") + @ExcludeMissing + fun _stop() = stop @JsonAnyGetter @ExcludeMissing @@ -591,66 +588,64 @@ private constructor( fun validate(): OpenAIModelParams = apply { if (!validated) { - useCache() - temperature() - topP() - maxTokens() - frequencyPenalty() - presencePenalty() - responseFormat()?.validate() - toolChoice() - functionCall() - n() - stop() - validated = true + useCache() + temperature() + topP() + maxTokens() + frequencyPenalty() + presencePenalty() + responseFormat()?.validate() + toolChoice() + functionCall() + n() + stop() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OpenAIModelParams && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topP == other.topP && - this.maxTokens == other.maxTokens && - this.frequencyPenalty == other.frequencyPenalty && - this.presencePenalty == other.presencePenalty && - this.responseFormat == other.responseFormat && - this.toolChoice == other.toolChoice && - this.functionCall == other.functionCall && - this.n == other.n && - this.stop == other.stop && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is OpenAIModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topP == other.topP && + this.maxTokens == other.maxTokens && + this.frequencyPenalty == other.frequencyPenalty && + this.presencePenalty == other.presencePenalty && + this.responseFormat == other.responseFormat && + this.toolChoice == other.toolChoice && + this.functionCall == other.functionCall && + this.n == other.n && + this.stop == other.stop && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" + override fun toString() = "OpenAIModelParams{useCache=$useCache, temperature=$temperature, topP=$topP, maxTokens=$maxTokens, frequencyPenalty=$frequencyPenalty, presencePenalty=$presencePenalty, responseFormat=$responseFormat, toolChoice=$toolChoice, functionCall=$functionCall, n=$n, stop=$stop, additionalProperties=$additionalProperties}" companion object { @@ -691,7 +686,9 @@ private constructor( @JsonProperty("use_cache") @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = apply { + this.useCache = useCache + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) @@ -705,7 +702,9 @@ private constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } + fun topP(topP: JsonField) = apply { + this.topP = topP + } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) @@ -715,8 +714,7 @@ private constructor( this.maxTokens = maxTokens } - fun frequencyPenalty(frequencyPenalty: Double) = - frequencyPenalty(JsonField.of(frequencyPenalty)) + fun frequencyPenalty(frequencyPenalty: Double) = frequencyPenalty(JsonField.of(frequencyPenalty)) @JsonProperty("frequency_penalty") @ExcludeMissing @@ -724,8 +722,7 @@ private constructor( this.frequencyPenalty = frequencyPenalty } - fun presencePenalty(presencePenalty: Double) = - presencePenalty(JsonField.of(presencePenalty)) + fun presencePenalty(presencePenalty: Double) = presencePenalty(JsonField.of(presencePenalty)) @JsonProperty("presence_penalty") @ExcludeMissing @@ -733,8 +730,7 @@ private constructor( this.presencePenalty = presencePenalty } - fun responseFormat(responseFormat: ResponseFormat) = - responseFormat(JsonField.of(responseFormat)) + fun responseFormat(responseFormat: ResponseFormat) = responseFormat(JsonField.of(responseFormat)) @JsonProperty("response_format") @ExcludeMissing @@ -750,8 +746,7 @@ private constructor( this.toolChoice = toolChoice } - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -763,13 +758,17 @@ private constructor( @JsonProperty("n") @ExcludeMissing - fun n(n: JsonField) = apply { this.n = n } + fun n(n: JsonField) = apply { + this.n = n + } fun stop(stop: List) = stop(JsonField.of(stop)) @JsonProperty("stop") @ExcludeMissing - fun stop(stop: JsonField>) = apply { this.stop = stop } + fun stop(stop: JsonField>) = apply { + this.stop = stop + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -781,106 +780,98 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): OpenAIModelParams = - OpenAIModelParams( - useCache, - temperature, - topP, - maxTokens, - frequencyPenalty, - presencePenalty, - responseFormat, - toolChoice, - functionCall, - n, - stop.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): OpenAIModelParams = OpenAIModelParams( + useCache, + temperature, + topP, + maxTokens, + frequencyPenalty, + presencePenalty, + responseFormat, + toolChoice, + functionCall, + n, + stop.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = FunctionCall.Deserializer::class) @JsonSerialize(using = FunctionCall.Serializer::class) - class FunctionCall - private constructor( - private val auto: Auto? = null, - private val none: None? = null, - private val function: Function? = null, - private val _json: JsonValue? = null, + class FunctionCall private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun auto(): Auto? = auto - fun none(): None? = none - fun function(): Function? = function fun isAuto(): Boolean = auto != null - fun isNone(): Boolean = none != null - fun isFunction(): Boolean = function != null fun asAuto(): Auto = auto.getOrThrow("auto") - fun asNone(): None = none.getOrThrow("none") - fun asFunction(): Function = function.getOrThrow("function") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - auto != null -> visitor.visitAuto(auto) - none != null -> visitor.visitNone(none) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): FunctionCall = apply { if (!validated) { - if (auto == null && none == null && function == null) { - throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") - } - function?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException("Unknown FunctionCall: $_json") + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.auto == other.auto && - this.none == other.none && - this.function == other.function + return other is FunctionCall && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - auto, - none, - function, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - auto != null -> "FunctionCall{auto=$auto}" - none != null -> "FunctionCall{none=$none}" - function != null -> "FunctionCall{function=$function}" - _json != null -> "FunctionCall{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FunctionCall") - } + return when { + auto != null -> "FunctionCall{auto=$auto}" + none != null -> "FunctionCall{none=$none}" + function != null -> "FunctionCall{function=$function}" + _json != null -> "FunctionCall{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FunctionCall") + } } companion object { @@ -901,61 +892,53 @@ private constructor( fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FunctionCall: $json") + throw BraintrustInvalidDataException("Unknown FunctionCall: $json") } } class Deserializer : BaseDeserializer(FunctionCall::class) { override fun ObjectCodec.deserialize(node: JsonNode): FunctionCall { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(auto = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return FunctionCall(none = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return FunctionCall(function = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return FunctionCall(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return FunctionCall(function = it, _json = json) + } - return FunctionCall(_json = json) + return FunctionCall(_json = json) } } class Serializer : BaseSerializer(FunctionCall::class) { - override fun serialize( - value: FunctionCall, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.auto != null -> generator.writeObject(value.auto) - value.none != null -> generator.writeObject(value.none) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FunctionCall") - } + override fun serialize(value: FunctionCall, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FunctionCall") + } } } - class Auto - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Auto @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Auto && this.value == other.value + return other is Auto && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -978,36 +961,31 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown Auto: $value") - } + fun known(): Known = when (this) { + AUTO -> Known.AUTO + else -> throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class None - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class None @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is None && this.value == other.value + return other is None && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1030,28 +1008,22 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown None: $value") - } + fun known(): Known = when (this) { + NONE -> Known.NONE + else -> throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { + class Function private constructor(private val name: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1059,7 +1031,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing @@ -1067,32 +1041,31 @@ private constructor( fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" companion object { @@ -1102,8 +1075,7 @@ private constructor( class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(function: Function) = apply { this.name = function.name @@ -1114,36 +1086,32 @@ private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Function = - Function(name, additionalProperties.toUnmodifiable()) + fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) } } } @JsonDeserialize(builder = ResponseFormat.Builder::class) @NoAutoDetect - class ResponseFormat - private constructor( - private val type: JsonField, - private val additionalProperties: Map, - ) { + class ResponseFormat private constructor(private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1151,7 +1119,9 @@ private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -1159,32 +1129,31 @@ private constructor( fun validate(): ResponseFormat = apply { if (!validated) { - type() - validated = true + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ResponseFormat && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ResponseFormat && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(type, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(type, additionalProperties) + } + return hashCode } - override fun toString() = - "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "ResponseFormat{type=$type, additionalProperties=$additionalProperties}" companion object { @@ -1194,8 +1163,7 @@ private constructor( class Builder { private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(responseFormat: ResponseFormat) = apply { this.type = responseFormat.type @@ -1206,42 +1174,39 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): ResponseFormat = - ResponseFormat(type, additionalProperties.toUnmodifiable()) + fun build(): ResponseFormat = ResponseFormat(type, additionalProperties.toUnmodifiable()) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1264,17 +1229,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - JSON_OBJECT -> Value.JSON_OBJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + JSON_OBJECT -> Value.JSON_OBJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - JSON_OBJECT -> Known.JSON_OBJECT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + JSON_OBJECT -> Known.JSON_OBJECT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1282,82 +1245,76 @@ private constructor( @JsonDeserialize(using = ToolChoice.Deserializer::class) @JsonSerialize(using = ToolChoice.Serializer::class) - class ToolChoice - private constructor( - private val auto: Auto? = null, - private val none: None? = null, - private val function: Function? = null, - private val _json: JsonValue? = null, + class ToolChoice private constructor( + private val auto: Auto? = null, + private val none: None? = null, + private val function: Function? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun auto(): Auto? = auto - fun none(): None? = none - fun function(): Function? = function fun isAuto(): Boolean = auto != null - fun isNone(): Boolean = none != null - fun isFunction(): Boolean = function != null fun asAuto(): Auto = auto.getOrThrow("auto") - fun asNone(): None = none.getOrThrow("none") - fun asFunction(): Function = function.getOrThrow("function") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - auto != null -> visitor.visitAuto(auto) - none != null -> visitor.visitNone(none) - function != null -> visitor.visitFunction(function) - else -> visitor.unknown(_json) - } + return when { + auto != null -> visitor.visitAuto(auto) + none != null -> visitor.visitNone(none) + function != null -> visitor.visitFunction(function) + else -> visitor.unknown(_json) + } } fun validate(): ToolChoice = apply { if (!validated) { - if (auto == null && none == null && function == null) { - throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") - } - function?.validate() - validated = true + if (auto == null && none == null && function == null) { + throw BraintrustInvalidDataException("Unknown ToolChoice: $_json") + } + function?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolChoice && - this.auto == other.auto && - this.none == other.none && - this.function == other.function + return other is ToolChoice && + this.auto == other.auto && + this.none == other.none && + this.function == other.function } override fun hashCode(): Int { - return Objects.hash( - auto, - none, - function, - ) + return Objects.hash( + auto, + none, + function, + ) } override fun toString(): String { - return when { - auto != null -> "ToolChoice{auto=$auto}" - none != null -> "ToolChoice{none=$none}" - function != null -> "ToolChoice{function=$function}" - _json != null -> "ToolChoice{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ToolChoice") - } + return when { + auto != null -> "ToolChoice{auto=$auto}" + none != null -> "ToolChoice{none=$none}" + function != null -> "ToolChoice{function=$function}" + _json != null -> "ToolChoice{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolChoice") + } } companion object { @@ -1378,61 +1335,53 @@ private constructor( fun visitFunction(function: Function): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown ToolChoice: $json") + throw BraintrustInvalidDataException("Unknown ToolChoice: $json") } } class Deserializer : BaseDeserializer(ToolChoice::class) { override fun ObjectCodec.deserialize(node: JsonNode): ToolChoice { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(auto = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return ToolChoice(none = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return ToolChoice(function = it, _json = json) - } + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(auto = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return ToolChoice(none = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return ToolChoice(function = it, _json = json) + } - return ToolChoice(_json = json) + return ToolChoice(_json = json) } } class Serializer : BaseSerializer(ToolChoice::class) { - override fun serialize( - value: ToolChoice, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.auto != null -> generator.writeObject(value.auto) - value.none != null -> generator.writeObject(value.none) - value.function != null -> generator.writeObject(value.function) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ToolChoice") - } + override fun serialize(value: ToolChoice, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.auto != null -> generator.writeObject(value.auto) + value.none != null -> generator.writeObject(value.none) + value.function != null -> generator.writeObject(value.function) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolChoice") + } } } - class Auto - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Auto @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Auto && this.value == other.value + return other is Auto && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1455,36 +1404,31 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + AUTO -> Value.AUTO + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - else -> throw BraintrustInvalidDataException("Unknown Auto: $value") - } + fun known(): Known = when (this) { + AUTO -> Known.AUTO + else -> throw BraintrustInvalidDataException("Unknown Auto: $value") + } fun asString(): String = _value().asStringOrThrow() } - class None - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class None @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is None && this.value == other.value + return other is None && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1507,29 +1451,22 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - NONE -> Value.NONE - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + NONE -> Value.NONE + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - NONE -> Known.NONE - else -> throw BraintrustInvalidDataException("Unknown None: $value") - } + fun known(): Known = when (this) { + NONE -> Known.NONE + else -> throw BraintrustInvalidDataException("Unknown None: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function - private constructor( - private val type: JsonField, - private val function: JsonField, - private val additionalProperties: Map, - ) { + class Function private constructor(private val type: JsonField, private val function: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1539,9 +1476,13 @@ private constructor( fun function(): Function = function.getRequired("function") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("function") @ExcludeMissing fun _function() = function + @JsonProperty("function") + @ExcludeMissing + fun _function() = function @JsonAnyGetter @ExcludeMissing @@ -1549,39 +1490,37 @@ private constructor( fun validate(): Function = apply { if (!validated) { - type() - function().validate() - validated = true + type() + function().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 other is Function && - this.type == other.type && - this.function == other.function && - this.additionalProperties == other.additionalProperties + return other is Function && + this.type == other.type && + this.function == other.function && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - function, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + function, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" + override fun toString() = "Function{type=$type, function=$function, additionalProperties=$additionalProperties}" companion object { @@ -1592,8 +1531,7 @@ private constructor( private var type: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(function: Function) = apply { this.type = function.type @@ -1605,7 +1543,9 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun function(function: Function) = function(JsonField.of(function)) @@ -1615,36 +1555,30 @@ private constructor( this.function = function } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Function = - Function( - type, - function, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = Function( + type, + function, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function - private constructor( - private val name: JsonField, - private val additionalProperties: Map, - ) { + class Function private constructor(private val name: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -1652,41 +1586,41 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Function = apply { if (!validated) { - name() - validated = true + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is Function && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(name, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(name, additionalProperties) + } + return hashCode } - override fun toString() = - "Function{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Function{name=$name, additionalProperties=$additionalProperties}" companion object { @@ -1696,8 +1630,7 @@ private constructor( class Builder { private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(function: Function) = apply { this.name = function.name @@ -1708,11 +1641,11 @@ private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -1722,30 +1655,26 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Function = - Function(name, additionalProperties.toUnmodifiable()) + fun build(): Function = Function(name, additionalProperties.toUnmodifiable()) } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1768,18 +1697,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + FUNCTION -> Known.FUNCTION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -1789,16 +1715,16 @@ private constructor( @JsonDeserialize(builder = AnthropicModelParams.Builder::class) @NoAutoDetect - class AnthropicModelParams - private constructor( - private val useCache: JsonField, - private val maxTokens: JsonField, - private val temperature: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val stopSequences: JsonField>, - private val maxTokensToSample: JsonField, - private val additionalProperties: Map, + class AnthropicModelParams private constructor( + private val useCache: JsonField, + private val maxTokens: JsonField, + private val temperature: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val stopSequences: JsonField>, + private val maxTokensToSample: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -1818,20 +1744,31 @@ private constructor( fun stopSequences(): List? = stopSequences.getNullable("stop_sequences") /** This is a legacy parameter that should not be used. */ - fun maxTokensToSample(): Double? = - maxTokensToSample.getNullable("max_tokens_to_sample") + fun maxTokensToSample(): Double? = maxTokensToSample.getNullable("max_tokens_to_sample") - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + @JsonProperty("use_cache") + @ExcludeMissing + fun _useCache() = useCache - @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens() = maxTokens + @JsonProperty("max_tokens") + @ExcludeMissing + fun _maxTokens() = maxTokens - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature() = temperature - @JsonProperty("top_p") @ExcludeMissing fun _topP() = topP + @JsonProperty("top_p") + @ExcludeMissing + fun _topP() = topP - @JsonProperty("top_k") @ExcludeMissing fun _topK() = topK + @JsonProperty("top_k") + @ExcludeMissing + fun _topK() = topK - @JsonProperty("stop_sequences") @ExcludeMissing fun _stopSequences() = stopSequences + @JsonProperty("stop_sequences") + @ExcludeMissing + fun _stopSequences() = stopSequences /** This is a legacy parameter that should not be used. */ @JsonProperty("max_tokens_to_sample") @@ -1844,54 +1781,52 @@ private constructor( fun validate(): AnthropicModelParams = apply { if (!validated) { - useCache() - maxTokens() - temperature() - topP() - topK() - stopSequences() - maxTokensToSample() - validated = true + useCache() + maxTokens() + temperature() + topP() + topK() + stopSequences() + maxTokensToSample() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AnthropicModelParams && - this.useCache == other.useCache && - this.maxTokens == other.maxTokens && - this.temperature == other.temperature && - this.topP == other.topP && - this.topK == other.topK && - this.stopSequences == other.stopSequences && - this.maxTokensToSample == other.maxTokensToSample && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AnthropicModelParams && + this.useCache == other.useCache && + this.maxTokens == other.maxTokens && + this.temperature == other.temperature && + this.topP == other.topP && + this.topK == other.topK && + this.stopSequences == other.stopSequences && + this.maxTokensToSample == other.maxTokensToSample && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences, - maxTokensToSample, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences, + maxTokensToSample, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" + override fun toString() = "AnthropicModelParams{useCache=$useCache, maxTokens=$maxTokens, temperature=$temperature, topP=$topP, topK=$topK, stopSequences=$stopSequences, maxTokensToSample=$maxTokensToSample, additionalProperties=$additionalProperties}" companion object { @@ -1924,7 +1859,9 @@ private constructor( @JsonProperty("use_cache") @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = apply { + this.useCache = useCache + } fun maxTokens(maxTokens: Double) = maxTokens(JsonField.of(maxTokens)) @@ -1946,16 +1883,19 @@ private constructor( @JsonProperty("top_p") @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } + fun topP(topP: JsonField) = apply { + this.topP = topP + } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("top_k") @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } + fun topK(topK: JsonField) = apply { + this.topK = topK + } - fun stopSequences(stopSequences: List) = - stopSequences(JsonField.of(stopSequences)) + fun stopSequences(stopSequences: List) = stopSequences(JsonField.of(stopSequences)) @JsonProperty("stop_sequences") @ExcludeMissing @@ -1964,8 +1904,7 @@ private constructor( } /** 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. */ @JsonProperty("max_tokens_to_sample") @@ -1984,35 +1923,33 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): AnthropicModelParams = - AnthropicModelParams( - useCache, - maxTokens, - temperature, - topP, - topK, - stopSequences.map { it.toUnmodifiable() }, - maxTokensToSample, - additionalProperties.toUnmodifiable(), - ) + fun build(): AnthropicModelParams = AnthropicModelParams( + useCache, + maxTokens, + temperature, + topP, + topK, + stopSequences.map { it.toUnmodifiable() }, + maxTokensToSample, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = GoogleModelParams.Builder::class) @NoAutoDetect - class GoogleModelParams - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val maxOutputTokens: JsonField, - private val topP: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, + class GoogleModelParams private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val maxOutputTokens: JsonField, + private val topP: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2029,17 +1966,25 @@ private constructor( fun topK(): Double? = topK.getNullable("topK") - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + @JsonProperty("use_cache") + @ExcludeMissing + fun _useCache() = useCache - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature() = temperature @JsonProperty("maxOutputTokens") @ExcludeMissing fun _maxOutputTokens() = maxOutputTokens - @JsonProperty("topP") @ExcludeMissing fun _topP() = topP + @JsonProperty("topP") + @ExcludeMissing + fun _topP() = topP - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK + @JsonProperty("topK") + @ExcludeMissing + fun _topK() = topK @JsonAnyGetter @ExcludeMissing @@ -2047,48 +1992,46 @@ private constructor( fun validate(): GoogleModelParams = apply { if (!validated) { - useCache() - temperature() - maxOutputTokens() - topP() - topK() - validated = true + useCache() + temperature() + maxOutputTokens() + topP() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GoogleModelParams && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.maxOutputTokens == other.maxOutputTokens && - this.topP == other.topP && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is GoogleModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.maxOutputTokens == other.maxOutputTokens && + this.topP == other.topP && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = "GoogleModelParams{useCache=$useCache, temperature=$temperature, maxOutputTokens=$maxOutputTokens, topP=$topP, topK=$topK, additionalProperties=$additionalProperties}" companion object { @@ -2117,7 +2060,9 @@ private constructor( @JsonProperty("use_cache") @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = apply { + this.useCache = useCache + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) @@ -2127,8 +2072,7 @@ private constructor( this.temperature = temperature } - fun maxOutputTokens(maxOutputTokens: Double) = - maxOutputTokens(JsonField.of(maxOutputTokens)) + fun maxOutputTokens(maxOutputTokens: Double) = maxOutputTokens(JsonField.of(maxOutputTokens)) @JsonProperty("maxOutputTokens") @ExcludeMissing @@ -2140,13 +2084,17 @@ private constructor( @JsonProperty("topP") @ExcludeMissing - fun topP(topP: JsonField) = apply { this.topP = topP } + fun topP(topP: JsonField) = apply { + this.topP = topP + } fun topK(topK: Double) = topK(JsonField.of(topK)) @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } + fun topK(topK: JsonField) = apply { + this.topK = topK + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2158,31 +2106,29 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): GoogleModelParams = - GoogleModelParams( - useCache, - temperature, - maxOutputTokens, - topP, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): GoogleModelParams = GoogleModelParams( + useCache, + temperature, + maxOutputTokens, + topP, + topK, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = WindowAiModelParams.Builder::class) @NoAutoDetect - class WindowAiModelParams - private constructor( - private val useCache: JsonField, - private val temperature: JsonField, - private val topK: JsonField, - private val additionalProperties: Map, + class WindowAiModelParams private constructor( + private val useCache: JsonField, + private val temperature: JsonField, + private val topK: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2195,11 +2141,17 @@ private constructor( fun topK(): Double? = topK.getNullable("topK") - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + @JsonProperty("use_cache") + @ExcludeMissing + fun _useCache() = useCache - @JsonProperty("temperature") @ExcludeMissing fun _temperature() = temperature + @JsonProperty("temperature") + @ExcludeMissing + fun _temperature() = temperature - @JsonProperty("topK") @ExcludeMissing fun _topK() = topK + @JsonProperty("topK") + @ExcludeMissing + fun _topK() = topK @JsonAnyGetter @ExcludeMissing @@ -2207,42 +2159,40 @@ private constructor( fun validate(): WindowAiModelParams = apply { if (!validated) { - useCache() - temperature() - topK() - validated = true + useCache() + temperature() + topK() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is WindowAiModelParams && - this.useCache == other.useCache && - this.temperature == other.temperature && - this.topK == other.topK && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is WindowAiModelParams && + this.useCache == other.useCache && + this.temperature == other.temperature && + this.topK == other.topK && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - useCache, - temperature, - topK, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + useCache, + temperature, + topK, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" + override fun toString() = "WindowAiModelParams{useCache=$useCache, temperature=$temperature, topK=$topK, additionalProperties=$additionalProperties}" companion object { @@ -2267,7 +2217,9 @@ private constructor( @JsonProperty("use_cache") @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = apply { + this.useCache = useCache + } fun temperature(temperature: Double) = temperature(JsonField.of(temperature)) @@ -2281,7 +2233,9 @@ private constructor( @JsonProperty("topK") @ExcludeMissing - fun topK(topK: JsonField) = apply { this.topK = topK } + fun topK(topK: JsonField) = apply { + this.topK = topK + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2293,28 +2247,22 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): WindowAiModelParams = - WindowAiModelParams( - useCache, - temperature, - topK, - additionalProperties.toUnmodifiable(), - ) + fun build(): WindowAiModelParams = WindowAiModelParams( + useCache, + temperature, + topK, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = JsCompletionParams.Builder::class) @NoAutoDetect - class JsCompletionParams - private constructor( - private val useCache: JsonField, - private val additionalProperties: Map, - ) { + class JsCompletionParams private constructor(private val useCache: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2322,7 +2270,9 @@ private constructor( fun useCache(): Boolean? = useCache.getNullable("use_cache") - @JsonProperty("use_cache") @ExcludeMissing fun _useCache() = useCache + @JsonProperty("use_cache") + @ExcludeMissing + fun _useCache() = useCache @JsonAnyGetter @ExcludeMissing @@ -2330,32 +2280,31 @@ private constructor( fun validate(): JsCompletionParams = apply { if (!validated) { - useCache() - validated = true + useCache() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is JsCompletionParams && - this.useCache == other.useCache && - this.additionalProperties == other.additionalProperties + return other is JsCompletionParams && + this.useCache == other.useCache && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(useCache, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(useCache, additionalProperties) + } + return hashCode } - override fun toString() = - "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" + override fun toString() = "JsCompletionParams{useCache=$useCache, additionalProperties=$additionalProperties}" companion object { @@ -2376,7 +2325,9 @@ private constructor( @JsonProperty("use_cache") @ExcludeMissing - fun useCache(useCache: JsonField) = apply { this.useCache = useCache } + fun useCache(useCache: JsonField) = apply { + this.useCache = useCache + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2388,13 +2339,11 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): JsCompletionParams = - JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) + fun build(): JsCompletionParams = JsCompletionParams(useCache, additionalProperties.toUnmodifiable()) } } } @@ -2402,12 +2351,12 @@ private constructor( @JsonDeserialize(builder = Origin.Builder::class) @NoAutoDetect - class Origin - private constructor( - private val promptId: JsonField, - private val projectId: JsonField, - private val promptVersion: JsonField, - private val additionalProperties: Map, + class Origin private constructor( + private val promptId: JsonField, + private val projectId: JsonField, + private val promptVersion: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2420,11 +2369,17 @@ private constructor( fun promptVersion(): String? = promptVersion.getNullable("prompt_version") - @JsonProperty("prompt_id") @ExcludeMissing fun _promptId() = promptId + @JsonProperty("prompt_id") + @ExcludeMissing + fun _promptId() = promptId - @JsonProperty("project_id") @ExcludeMissing fun _projectId() = projectId + @JsonProperty("project_id") + @ExcludeMissing + fun _projectId() = projectId - @JsonProperty("prompt_version") @ExcludeMissing fun _promptVersion() = promptVersion + @JsonProperty("prompt_version") + @ExcludeMissing + fun _promptVersion() = promptVersion @JsonAnyGetter @ExcludeMissing @@ -2432,42 +2387,40 @@ private constructor( fun validate(): Origin = apply { if (!validated) { - promptId() - projectId() - promptVersion() - validated = true + promptId() + projectId() + promptVersion() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Origin && - this.promptId == other.promptId && - this.projectId == other.projectId && - this.promptVersion == other.promptVersion && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Origin && + this.promptId == other.promptId && + this.projectId == other.projectId && + this.promptVersion == other.promptVersion && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - promptId, - projectId, - promptVersion, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + promptId, + projectId, + promptVersion, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" + override fun toString() = "Origin{promptId=$promptId, projectId=$projectId, promptVersion=$promptVersion, additionalProperties=$additionalProperties}" companion object { @@ -2492,13 +2445,17 @@ private constructor( @JsonProperty("prompt_id") @ExcludeMissing - fun promptId(promptId: JsonField) = apply { this.promptId = promptId } + fun promptId(promptId: JsonField) = apply { + this.promptId = promptId + } fun projectId(projectId: String) = projectId(JsonField.of(projectId)) @JsonProperty("project_id") @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } fun promptVersion(promptVersion: String) = promptVersion(JsonField.of(promptVersion)) @@ -2522,24 +2479,23 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Origin = - Origin( - promptId, - projectId, - promptVersion, - additionalProperties.toUnmodifiable(), - ) + fun build(): Origin = Origin( + promptId, + projectId, + promptVersion, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = Parser.Builder::class) @NoAutoDetect - class Parser - private constructor( - private val type: JsonField, - private val useCot: JsonField, - private val choiceScores: JsonField, - private val additionalProperties: Map, + class Parser private constructor( + private val type: JsonField, + private val useCot: JsonField, + private val choiceScores: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -2552,11 +2508,17 @@ private constructor( fun choiceScores(): ChoiceScores = choiceScores.getRequired("choice_scores") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("use_cot") @ExcludeMissing fun _useCot() = useCot + @JsonProperty("use_cot") + @ExcludeMissing + fun _useCot() = useCot - @JsonProperty("choice_scores") @ExcludeMissing fun _choiceScores() = choiceScores + @JsonProperty("choice_scores") + @ExcludeMissing + fun _choiceScores() = choiceScores @JsonAnyGetter @ExcludeMissing @@ -2564,42 +2526,40 @@ private constructor( fun validate(): Parser = apply { if (!validated) { - type() - useCot() - choiceScores().validate() - validated = true + type() + useCot() + choiceScores().validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parser && - this.type == other.type && - this.useCot == other.useCot && - this.choiceScores == other.choiceScores && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Parser && + this.type == other.type && + this.useCot == other.useCot && + this.choiceScores == other.choiceScores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - useCot, - choiceScores, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + useCot, + choiceScores, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Parser{type=$type, useCot=$useCot, choiceScores=$choiceScores, additionalProperties=$additionalProperties}" + override fun toString() = "Parser{type=$type, useCot=$useCot, choiceScores=$choiceScores, additionalProperties=$additionalProperties}" companion object { @@ -2624,13 +2584,17 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun useCot(useCot: Boolean) = useCot(JsonField.of(useCot)) @JsonProperty("use_cot") @ExcludeMissing - fun useCot(useCot: JsonField) = apply { this.useCot = useCot } + fun useCot(useCot: JsonField) = apply { + this.useCot = useCot + } fun choiceScores(choiceScores: ChoiceScores) = choiceScores(JsonField.of(choiceScores)) @@ -2654,21 +2618,17 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Parser = - Parser( - type, - useCot, - choiceScores, - additionalProperties.toUnmodifiable(), - ) + fun build(): Parser = Parser( + type, + useCot, + choiceScores, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ChoiceScores.Builder::class) @NoAutoDetect - class ChoiceScores - private constructor( - private val additionalProperties: Map, - ) { + class ChoiceScores private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2680,26 +2640,26 @@ private constructor( fun validate(): ChoiceScores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ChoiceScores && - this.additionalProperties == other.additionalProperties + return other is ChoiceScores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ChoiceScores{additionalProperties=$additionalProperties}" @@ -2727,29 +2687,26 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } fun build(): ChoiceScores = ChoiceScores(additionalProperties.toUnmodifiable()) } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -2772,17 +2729,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - LLM_CLASSIFIER -> Value.LLM_CLASSIFIER - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + LLM_CLASSIFIER -> Value.LLM_CLASSIFIER + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - LLM_CLASSIFIER -> Known.LLM_CLASSIFIER - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + LLM_CLASSIFIER -> Known.LLM_CLASSIFIER + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -2790,84 +2745,78 @@ private constructor( @JsonDeserialize(using = Prompt.Deserializer::class) @JsonSerialize(using = Prompt.Serializer::class) - class Prompt - private constructor( - private val completion: Completion? = null, - private val chat: Chat? = null, - private val nullableVariant: NullableVariant? = null, - private val _json: JsonValue? = null, + class Prompt private constructor( + private val completion: Completion? = null, + private val chat: Chat? = null, + private val nullableVariant: NullableVariant? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun completion(): Completion? = completion - fun chat(): Chat? = chat - fun nullableVariant(): NullableVariant? = nullableVariant fun isCompletion(): Boolean = completion != null - fun isChat(): Boolean = chat != null - fun isNullableVariant(): Boolean = nullableVariant != null fun asCompletion(): Completion = completion.getOrThrow("completion") - fun asChat(): Chat = chat.getOrThrow("chat") - fun asNullableVariant(): NullableVariant = nullableVariant.getOrThrow("nullableVariant") fun _json(): JsonValue? = _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) + } } fun validate(): Prompt = apply { if (!validated) { - if (completion == null && chat == null && nullableVariant == null) { - throw BraintrustInvalidDataException("Unknown Prompt: $_json") - } - completion?.validate() - chat?.validate() - nullableVariant?.validate() - validated = true + if (completion == null && chat == null && nullableVariant == null) { + throw BraintrustInvalidDataException("Unknown Prompt: $_json") + } + completion?.validate() + chat?.validate() + nullableVariant?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Prompt && - this.completion == other.completion && - this.chat == other.chat && - this.nullableVariant == other.nullableVariant + if (this === other) { + return true + } + + return other is Prompt && + this.completion == other.completion && + this.chat == other.chat && + this.nullableVariant == other.nullableVariant } override fun hashCode(): Int { - return Objects.hash( - completion, - chat, - nullableVariant, - ) + return Objects.hash( + completion, + chat, + nullableVariant, + ) } override fun toString(): String { - return when { - completion != null -> "Prompt{completion=$completion}" - chat != null -> "Prompt{chat=$chat}" - nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" - _json != null -> "Prompt{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Prompt") - } + return when { + completion != null -> "Prompt{completion=$completion}" + chat != null -> "Prompt{chat=$chat}" + nullableVariant != null -> "Prompt{nullableVariant=$nullableVariant}" + _json != null -> "Prompt{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Prompt") + } } companion object { @@ -2876,8 +2825,7 @@ private constructor( fun ofChat(chat: Chat) = Prompt(chat = chat) - fun ofNullableVariant(nullableVariant: NullableVariant) = - Prompt(nullableVariant = nullableVariant) + fun ofNullableVariant(nullableVariant: NullableVariant) = Prompt(nullableVariant = nullableVariant) } interface Visitor { @@ -2889,56 +2837,44 @@ private constructor( fun visitNullableVariant(nullableVariant: NullableVariant): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Prompt: $json") + throw BraintrustInvalidDataException("Unknown Prompt: $json") } } 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) } } 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") + } } } @JsonDeserialize(builder = Completion.Builder::class) @NoAutoDetect - class Completion - private constructor( - private val type: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { + class Completion private constructor(private val type: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -2948,9 +2884,13 @@ private constructor( fun content(): String = content.getRequired("content") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") + @ExcludeMissing + fun _content() = content @JsonAnyGetter @ExcludeMissing @@ -2958,39 +2898,37 @@ private constructor( fun validate(): Completion = apply { if (!validated) { - type() - content() - validated = true + type() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Completion && - this.type == other.type && - this.content == other.content && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Completion && + this.type == other.type && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = "Completion{type=$type, content=$content, additionalProperties=$additionalProperties}" companion object { @@ -3013,13 +2951,17 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3031,33 +2973,29 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Completion = - Completion( - type, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Completion = Completion( + type, + content, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -3080,17 +3018,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - COMPLETION -> Value.COMPLETION - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + COMPLETION -> Value.COMPLETION + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - COMPLETION -> Known.COMPLETION - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + COMPLETION -> Known.COMPLETION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -3098,12 +3034,12 @@ private constructor( @JsonDeserialize(builder = Chat.Builder::class) @NoAutoDetect - class Chat - private constructor( - private val type: JsonField, - private val messages: JsonField>, - private val tools: JsonField, - private val additionalProperties: Map, + class Chat private constructor( + private val type: JsonField, + private val messages: JsonField>, + private val tools: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3116,11 +3052,17 @@ private constructor( fun tools(): String? = tools.getNullable("tools") - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type - @JsonProperty("messages") @ExcludeMissing fun _messages() = messages + @JsonProperty("messages") + @ExcludeMissing + fun _messages() = messages - @JsonProperty("tools") @ExcludeMissing fun _tools() = tools + @JsonProperty("tools") + @ExcludeMissing + fun _tools() = tools @JsonAnyGetter @ExcludeMissing @@ -3128,42 +3070,40 @@ private constructor( fun validate(): Chat = apply { if (!validated) { - type() - messages() - tools() - validated = true + type() + messages() + tools() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Chat && - this.type == other.type && - this.messages == other.messages && - this.tools == other.tools && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Chat && + this.type == other.type && + this.messages == other.messages && + this.tools == other.tools && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - type, - messages, - tools, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + type, + messages, + tools, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" + override fun toString() = "Chat{type=$type, messages=$messages, tools=$tools, additionalProperties=$additionalProperties}" companion object { @@ -3188,7 +3128,9 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } fun messages(messages: List) = messages(JsonField.of(messages)) @@ -3202,7 +3144,9 @@ private constructor( @JsonProperty("tools") @ExcludeMissing - fun tools(tools: JsonField) = apply { this.tools = tools } + fun tools(tools: JsonField) = apply { + this.tools = tools + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3214,143 +3158,119 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Chat = - Chat( - type, - messages.map { it.toUnmodifiable() }, - tools, - additionalProperties.toUnmodifiable(), - ) + fun build(): Chat = Chat( + type, + messages.map { it.toUnmodifiable() }, + tools, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(using = Message.Deserializer::class) @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( - private val system: System? = null, - private val user: User? = null, - private val assistant: Assistant? = null, - private val tool: Tool? = null, - private val function: Function? = null, - private val fallback: Fallback? = null, - private val _json: JsonValue? = null, + class Message private constructor( + private val system: System? = null, + private val user: User? = null, + private val assistant: Assistant? = null, + private val tool: Tool? = null, + private val function: Function? = null, + private val fallback: Fallback? = null, + private val _json: JsonValue? = null, + ) { private var validated: Boolean = false fun system(): System? = system - fun user(): User? = user - fun assistant(): Assistant? = assistant - fun tool(): Tool? = tool - fun function(): Function? = function - fun fallback(): Fallback? = fallback fun isSystem(): Boolean = system != null - fun isUser(): Boolean = user != null - fun isAssistant(): Boolean = assistant != null - fun isTool(): Boolean = tool != null - fun isFunction(): Boolean = function != null - fun isFallback(): Boolean = fallback != null fun asSystem(): System = system.getOrThrow("system") - fun asUser(): User = user.getOrThrow("user") - fun asAssistant(): Assistant = assistant.getOrThrow("assistant") - fun asTool(): Tool = tool.getOrThrow("tool") - fun asFunction(): Function = function.getOrThrow("function") - fun asFallback(): Fallback = fallback.getOrThrow("fallback") fun _json(): JsonValue? = _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) + } } fun validate(): Message = apply { if (!validated) { - if ( - system == null && - user == null && - assistant == null && - tool == null && - function == null && - fallback == null - ) { - throw BraintrustInvalidDataException("Unknown Message: $_json") - } - system?.validate() - user?.validate() - assistant?.validate() - tool?.validate() - function?.validate() - fallback?.validate() - validated = true + if (system == null && user == null && assistant == null && tool == null && function == null && fallback == null) { + throw BraintrustInvalidDataException("Unknown Message: $_json") + } + system?.validate() + user?.validate() + assistant?.validate() + tool?.validate() + function?.validate() + fallback?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - this.system == other.system && - this.user == other.user && - this.assistant == other.assistant && - this.tool == other.tool && - this.function == other.function && - this.fallback == other.fallback + if (this === other) { + return true + } + + return other is Message && + this.system == other.system && + this.user == other.user && + this.assistant == other.assistant && + this.tool == other.tool && + this.function == other.function && + this.fallback == other.fallback } override fun hashCode(): Int { - return Objects.hash( - system, - user, - assistant, - tool, - function, - fallback, - ) + return Objects.hash( + system, + user, + assistant, + tool, + function, + fallback, + ) } override fun toString(): String { - return when { - system != null -> "Message{system=$system}" - user != null -> "Message{user=$user}" - assistant != null -> "Message{assistant=$assistant}" - tool != null -> "Message{tool=$tool}" - function != null -> "Message{function=$function}" - fallback != null -> "Message{fallback=$fallback}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } + return when { + system != null -> "Message{system=$system}" + user != null -> "Message{user=$user}" + assistant != null -> "Message{assistant=$assistant}" + tool != null -> "Message{tool=$tool}" + function != null -> "Message{function=$function}" + fallback != null -> "Message{fallback=$fallback}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } } companion object { @@ -3383,71 +3303,61 @@ private constructor( fun visitFallback(fallback: Fallback): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Message: $json") + throw BraintrustInvalidDataException("Unknown Message: $json") } } class Deserializer : BaseDeserializer(Message::class) { override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(system = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(user = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(assistant = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(tool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(function = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Message(fallback = it, _json = json) - } - - return Message(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(system = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(user = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(assistant = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(tool = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(function = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return Message(fallback = it, _json = json) + } + + return Message(_json = json) } } class Serializer : BaseSerializer(Message::class) { - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.system != null -> generator.writeObject(value.system) - value.user != null -> generator.writeObject(value.user) - value.assistant != null -> generator.writeObject(value.assistant) - value.tool != null -> generator.writeObject(value.tool) - value.function != null -> generator.writeObject(value.function) - value.fallback != null -> generator.writeObject(value.fallback) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } + override fun serialize(value: Message, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.system != null -> generator.writeObject(value.system) + value.user != null -> generator.writeObject(value.user) + value.assistant != null -> generator.writeObject(value.assistant) + value.tool != null -> generator.writeObject(value.tool) + value.function != null -> generator.writeObject(value.function) + value.fallback != null -> generator.writeObject(value.fallback) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } } } @JsonDeserialize(builder = System.Builder::class) @NoAutoDetect - class System - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + class System private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3460,11 +3370,17 @@ private constructor( fun name(): String? = name.getNullable("name") - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") + @ExcludeMissing + fun _content() = content - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") + @ExcludeMissing + fun _role() = role - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing @@ -3472,42 +3388,40 @@ private constructor( fun validate(): System = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is System && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is System && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "System{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -3519,8 +3433,7 @@ private constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(system: System) = apply { this.content = system.content @@ -3533,59 +3446,60 @@ private constructor( @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = apply { + this.role = role + } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): System = - System( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): System = System( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && this.value == other.value + return other is Role && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -3608,17 +3522,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - SYSTEM -> Value.SYSTEM - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + SYSTEM -> Value.SYSTEM + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - SYSTEM -> Known.SYSTEM - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = when (this) { + SYSTEM -> Known.SYSTEM + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -3626,12 +3538,12 @@ private constructor( @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect - class User - private constructor( - private val content: JsonField, - private val role: JsonField, - private val name: JsonField, - private val additionalProperties: Map, + class User private constructor( + private val content: JsonField, + private val role: JsonField, + private val name: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -3644,11 +3556,17 @@ private constructor( fun name(): String? = name.getNullable("name") - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") + @ExcludeMissing + fun _content() = content - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") + @ExcludeMissing + fun _role() = role - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing @@ -3656,42 +3574,40 @@ private constructor( fun validate(): User = apply { if (!validated) { - content() - role() - name() - validated = true + content() + role() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is User && - this.content == other.content && - this.role == other.role && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is User && + this.content == other.content && + this.role == other.role && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + content, + role, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "User{content=$content, role=$role, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -3703,8 +3619,7 @@ private constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(user: User) = apply { this.content = user.content @@ -3717,59 +3632,60 @@ private constructor( @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = apply { + this.role = role + } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): User = - User( - content, - role, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = User( + content, + role, + name, + additionalProperties.toUnmodifiable(), + ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && this.value == other.value + return other is Role && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -3792,243 +3708,185 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - USER -> Known.USER - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = when (this) { + USER -> Known.USER + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Content.Deserializer::class) @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val string: String? = null, - private val unnamedSchemaWithArrayParent2s: - List? = - null, - private val _json: JsonValue? = null, - ) { + class Content private constructor(private val string: String? = null, private val unnamedSchemaWithArrayParent2s: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - - fun unnamedSchemaWithArrayParent2s(): List? = - unnamedSchemaWithArrayParent2s + fun unnamedSchemaWithArrayParent2s(): List? = unnamedSchemaWithArrayParent2s fun isString(): Boolean = string != null - - fun isUnnamedSchemaWithArrayParent2s(): Boolean = - unnamedSchemaWithArrayParent2s != null + fun isUnnamedSchemaWithArrayParent2s(): Boolean = unnamedSchemaWithArrayParent2s != null fun asString(): String = string.getOrThrow("string") - - fun asUnnamedSchemaWithArrayParent2s(): - List = - unnamedSchemaWithArrayParent2s.getOrThrow( - "unnamedSchemaWithArrayParent2s" - ) + fun asUnnamedSchemaWithArrayParent2s(): List = unnamedSchemaWithArrayParent2s.getOrThrow("unnamedSchemaWithArrayParent2s") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - unnamedSchemaWithArrayParent2s != null -> - visitor.visitUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s - ) - else -> visitor.unknown(_json) - } + return when { + string != null -> visitor.visitString(string) + unnamedSchemaWithArrayParent2s != null -> visitor.visitUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s) + else -> visitor.unknown(_json) + } } fun validate(): Content = apply { if (!validated) { - if (string == null && unnamedSchemaWithArrayParent2s == null) { - throw BraintrustInvalidDataException("Unknown Content: $_json") - } - validated = true + if (string == null && unnamedSchemaWithArrayParent2s == null) { + throw BraintrustInvalidDataException("Unknown Content: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Content && - this.string == other.string && - this.unnamedSchemaWithArrayParent2s == - other.unnamedSchemaWithArrayParent2s + return other is Content && + this.string == other.string && + this.unnamedSchemaWithArrayParent2s == other.unnamedSchemaWithArrayParent2s } override fun hashCode(): Int { - return Objects.hash(string, unnamedSchemaWithArrayParent2s) + return Objects.hash(string, unnamedSchemaWithArrayParent2s) } override fun toString(): String { - return when { - string != null -> "Content{string=$string}" - unnamedSchemaWithArrayParent2s != null -> - "Content{unnamedSchemaWithArrayParent2s=$unnamedSchemaWithArrayParent2s}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } + return when { + string != null -> "Content{string=$string}" + unnamedSchemaWithArrayParent2s != null -> "Content{unnamedSchemaWithArrayParent2s=$unnamedSchemaWithArrayParent2s}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } } companion object { fun ofString(string: String) = Content(string = string) - fun ofUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ) = - Content( - unnamedSchemaWithArrayParent2s = unnamedSchemaWithArrayParent2s - ) + fun ofUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s: List) = Content(unnamedSchemaWithArrayParent2s = unnamedSchemaWithArrayParent2s) } interface Visitor { fun visitString(string: String): T - fun visitUnnamedSchemaWithArrayParent2s( - unnamedSchemaWithArrayParent2s: List - ): T + fun visitUnnamedSchemaWithArrayParent2s(unnamedSchemaWithArrayParent2s: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Content: $json") + throw BraintrustInvalidDataException("Unknown Content: $json") } } class Deserializer : BaseDeserializer(Content::class) { override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Content(string = it, _json = json) - } - tryDeserialize( - node, - jacksonTypeRef>() - ) - ?.let { - return Content( - unnamedSchemaWithArrayParent2s = it, - _json = json - ) - } - - return Content(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Content(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Content(unnamedSchemaWithArrayParent2s = it, _json = json) + } + + return Content(_json = json) } } class Serializer : BaseSerializer(Content::class) { - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.unnamedSchemaWithArrayParent2s != null -> - generator.writeObject(value.unnamedSchemaWithArrayParent2s) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } + override fun serialize(value: Content, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.unnamedSchemaWithArrayParent2s != null -> generator.writeObject(value.unnamedSchemaWithArrayParent2s) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } } } @JsonDeserialize(using = UnnamedSchemaWithArrayParent2.Deserializer::class) @JsonSerialize(using = UnnamedSchemaWithArrayParent2.Serializer::class) - class UnnamedSchemaWithArrayParent2 - private constructor( - private val text: Text? = null, - private val imageUrl: ImageUrl? = null, - private val _json: JsonValue? = null, - ) { + class UnnamedSchemaWithArrayParent2 private constructor(private val text: Text? = null, private val imageUrl: ImageUrl? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun text(): Text? = text - fun imageUrl(): ImageUrl? = imageUrl fun isText(): Boolean = text != null - fun isImageUrl(): Boolean = imageUrl != null fun asText(): Text = text.getOrThrow("text") - fun asImageUrl(): ImageUrl = imageUrl.getOrThrow("imageUrl") fun _json(): JsonValue? = _json fun accept(visitor: Visitor): T { - return when { - text != null -> visitor.visitText(text) - imageUrl != null -> visitor.visitImageUrl(imageUrl) - else -> visitor.unknown(_json) - } + return when { + text != null -> visitor.visitText(text) + imageUrl != null -> visitor.visitImageUrl(imageUrl) + else -> visitor.unknown(_json) + } } fun validate(): UnnamedSchemaWithArrayParent2 = apply { if (!validated) { - if (text == null && imageUrl == null) { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent2: $_json" - ) - } - text?.validate() - imageUrl?.validate() - validated = true + if (text == null && imageUrl == null) { + throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent2: $_json") + } + text?.validate() + imageUrl?.validate() + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is UnnamedSchemaWithArrayParent2 && - this.text == other.text && - this.imageUrl == other.imageUrl + return other is UnnamedSchemaWithArrayParent2 && + this.text == other.text && + this.imageUrl == other.imageUrl } override fun hashCode(): Int { - return Objects.hash(text, imageUrl) + return Objects.hash(text, imageUrl) } override fun toString(): String { - return when { - text != null -> "UnnamedSchemaWithArrayParent2{text=$text}" - imageUrl != null -> - "UnnamedSchemaWithArrayParent2{imageUrl=$imageUrl}" - _json != null -> - "UnnamedSchemaWithArrayParent2{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent2" - ) - } + return when { + text != null -> "UnnamedSchemaWithArrayParent2{text=$text}" + imageUrl != null -> "UnnamedSchemaWithArrayParent2{imageUrl=$imageUrl}" + _json != null -> "UnnamedSchemaWithArrayParent2{_unknown=$_json}" + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") + } } companion object { fun ofText(text: Text) = UnnamedSchemaWithArrayParent2(text = text) - fun ofImageUrl(imageUrl: ImageUrl) = - UnnamedSchemaWithArrayParent2(imageUrl = imageUrl) + fun ofImageUrl(imageUrl: ImageUrl) = UnnamedSchemaWithArrayParent2(imageUrl = imageUrl) } interface Visitor { @@ -4038,73 +3896,40 @@ private constructor( fun visitImageUrl(imageUrl: ImageUrl): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException( - "Unknown UnnamedSchemaWithArrayParent2: $json" - ) + throw BraintrustInvalidDataException("Unknown UnnamedSchemaWithArrayParent2: $json") } } - class Deserializer : - BaseDeserializer( - UnnamedSchemaWithArrayParent2::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): UnnamedSchemaWithArrayParent2 { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return UnnamedSchemaWithArrayParent2( - text = it, - _json = json - ) - } - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return UnnamedSchemaWithArrayParent2( - imageUrl = it, - _json = json - ) - } + class Deserializer : BaseDeserializer(UnnamedSchemaWithArrayParent2::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): UnnamedSchemaWithArrayParent2 { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return UnnamedSchemaWithArrayParent2(text = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()){ it.validate() }?.let { + return UnnamedSchemaWithArrayParent2(imageUrl = it, _json = json) + } - return UnnamedSchemaWithArrayParent2(_json = json) + return UnnamedSchemaWithArrayParent2(_json = json) } } - class Serializer : - BaseSerializer( - UnnamedSchemaWithArrayParent2::class - ) { - - override fun serialize( - value: UnnamedSchemaWithArrayParent2, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.text != null -> generator.writeObject(value.text) - value.imageUrl != null -> - generator.writeObject(value.imageUrl) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid UnnamedSchemaWithArrayParent2" - ) - } + class Serializer : BaseSerializer(UnnamedSchemaWithArrayParent2::class) { + + override fun serialize(value: UnnamedSchemaWithArrayParent2, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.text != null -> generator.writeObject(value.text) + value.imageUrl != null -> generator.writeObject(value.imageUrl) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid UnnamedSchemaWithArrayParent2") + } } } @JsonDeserialize(builder = Text.Builder::class) @NoAutoDetect - class Text - private constructor( - private val text: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { + class Text private constructor(private val text: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4114,50 +3939,51 @@ private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("text") @ExcludeMissing fun _text() = text + @JsonProperty("text") + @ExcludeMissing + fun _text() = text - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Text = apply { if (!validated) { - text() - type() - validated = true + text() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Text && - this.text == other.text && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Text && + this.text == other.text && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - text, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + text, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Text{text=$text, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -4168,9 +3994,7 @@ private constructor( private var text: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(text: Text) = apply { this.text = text.text @@ -4182,56 +4006,51 @@ private constructor( @JsonProperty("text") @ExcludeMissing - fun text(text: JsonField) = apply { this.text = text } + fun text(text: JsonField) = apply { + this.text = text + } fun type(type: Type) = type(JsonField.of(type)) @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): Text = - Text( - text, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): Text = Text( + text, + type, + additionalProperties.toUnmodifiable(), + ) } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -4254,20 +4073,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } + fun known(): Known = when (this) { + TEXT -> Known.TEXT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -4275,12 +4089,7 @@ private constructor( @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class ImageUrl - private constructor( - private val imageUrl: JsonField, - private val type: JsonField, - private val additionalProperties: Map, - ) { + class ImageUrl private constructor(private val imageUrl: JsonField, private val type: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4294,48 +4103,47 @@ private constructor( @ExcludeMissing fun _imageUrl() = imageUrl - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): ImageUrl = apply { if (!validated) { - imageUrl().validate() - type() - validated = true + imageUrl().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.imageUrl == other.imageUrl && - this.type == other.type && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.imageUrl == other.imageUrl && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - imageUrl, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + imageUrl, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "ImageUrl{imageUrl=$imageUrl, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -4346,9 +4154,7 @@ private constructor( private var imageUrl: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(imageUrl: ImageUrl) = apply { this.imageUrl = imageUrl.imageUrl @@ -4356,8 +4162,7 @@ private constructor( additionalProperties(imageUrl.additionalProperties) } - fun imageUrl(imageUrl: ImageUrl) = - imageUrl(JsonField.of(imageUrl)) + fun imageUrl(imageUrl: ImageUrl) = imageUrl(JsonField.of(imageUrl)) @JsonProperty("image_url") @ExcludeMissing @@ -4369,43 +4174,34 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ImageUrl = - ImageUrl( - imageUrl, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = ImageUrl( + imageUrl, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ImageUrl.Builder::class) @NoAutoDetect - class ImageUrl - private constructor( - private val url: JsonField, - private val detail: JsonField, - private val additionalProperties: Map, - ) { + class ImageUrl private constructor(private val url: JsonField, private val detail: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4415,50 +4211,51 @@ private constructor( fun detail(): Detail? = detail.getNullable("detail") - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") + @ExcludeMissing + fun _url() = url - @JsonProperty("detail") @ExcludeMissing fun _detail() = detail + @JsonProperty("detail") + @ExcludeMissing + fun _detail() = detail @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): ImageUrl = apply { if (!validated) { - url() - detail() - validated = true + url() + detail() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ImageUrl && - this.url == other.url && - this.detail == other.detail && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ImageUrl && + this.url == other.url && + this.detail == other.detail && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - url, - detail, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + url, + detail, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" + override fun toString() = "ImageUrl{url=$url, detail=$detail, additionalProperties=$additionalProperties}" companion object { @@ -4469,9 +4266,7 @@ private constructor( private var url: JsonField = JsonMissing.of() private var detail: JsonField = JsonMissing.of() - private var additionalProperties: - MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(imageUrl: ImageUrl) = apply { this.url = imageUrl.url @@ -4483,7 +4278,9 @@ private constructor( @JsonProperty("url") @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } + fun url(url: JsonField) = apply { + this.url = url + } fun detail(detail: Detail) = detail(JsonField.of(detail)) @@ -4493,48 +4290,39 @@ private constructor( this.detail = detail } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = - apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) } - fun build(): ImageUrl = - ImageUrl( - url, - detail, - additionalProperties.toUnmodifiable(), - ) + fun build(): ImageUrl = ImageUrl( + url, + detail, + additionalProperties.toUnmodifiable(), + ) } - class Detail - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Detail @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Detail && this.value == other.value + return other is Detail && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -4565,44 +4353,36 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - AUTO -> Value.AUTO - LOW -> Value.LOW - HIGH -> Value.HIGH - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - AUTO -> Known.AUTO - LOW -> Known.LOW - HIGH -> Known.HIGH - else -> - throw BraintrustInvalidDataException( - "Unknown Detail: $value" - ) - } + fun value(): Value = when (this) { + AUTO -> Value.AUTO + LOW -> Value.LOW + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + AUTO -> Known.AUTO + LOW -> Known.LOW + HIGH -> Known.HIGH + else -> throw BraintrustInvalidDataException("Unknown Detail: $value") + } fun asString(): String = _value().asStringOrThrow() } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -4625,20 +4405,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - IMAGE_URL -> Value.IMAGE_URL - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + IMAGE_URL -> Value.IMAGE_URL + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - IMAGE_URL -> Known.IMAGE_URL - else -> - throw BraintrustInvalidDataException( - "Unknown Type: $value" - ) - } + fun known(): Known = when (this) { + IMAGE_URL -> Known.IMAGE_URL + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -4649,14 +4424,14 @@ private constructor( @JsonDeserialize(builder = Assistant.Builder::class) @NoAutoDetect - class Assistant - private constructor( - private val role: JsonField, - private val content: JsonField, - private val functionCall: JsonField, - private val name: JsonField, - private val toolCalls: JsonField>, - private val additionalProperties: Map, + class Assistant private constructor( + private val role: JsonField, + private val content: JsonField, + private val functionCall: JsonField, + private val name: JsonField, + private val toolCalls: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -4673,17 +4448,25 @@ private constructor( fun toolCalls(): List? = toolCalls.getNullable("tool_calls") - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") + @ExcludeMissing + fun _role() = role - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") + @ExcludeMissing + fun _content() = content @JsonProperty("function_call") @ExcludeMissing fun _functionCall() = functionCall - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name - @JsonProperty("tool_calls") @ExcludeMissing fun _toolCalls() = toolCalls + @JsonProperty("tool_calls") + @ExcludeMissing + fun _toolCalls() = toolCalls @JsonAnyGetter @ExcludeMissing @@ -4691,48 +4474,46 @@ private constructor( fun validate(): Assistant = apply { if (!validated) { - role() - content() - functionCall()?.validate() - name() - toolCalls()?.forEach { it.validate() } - validated = true + role() + content() + functionCall()?.validate() + name() + toolCalls()?.forEach { 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 other is Assistant && - this.role == other.role && - this.content == other.content && - this.functionCall == other.functionCall && - this.name == other.name && - this.toolCalls == other.toolCalls && - this.additionalProperties == other.additionalProperties + return other is Assistant && + this.role == other.role && + this.content == other.content && + this.functionCall == other.functionCall && + this.name == other.name && + this.toolCalls == other.toolCalls && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - functionCall, - name, - toolCalls, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + role, + content, + functionCall, + name, + toolCalls, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" + override fun toString() = "Assistant{role=$role, content=$content, functionCall=$functionCall, name=$name, toolCalls=$toolCalls, additionalProperties=$additionalProperties}" companion object { @@ -4746,8 +4527,7 @@ private constructor( private var functionCall: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var toolCalls: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(assistant: Assistant) = apply { this.role = assistant.role @@ -4762,16 +4542,19 @@ private constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } - fun functionCall(functionCall: FunctionCall) = - functionCall(JsonField.of(functionCall)) + fun functionCall(functionCall: FunctionCall) = functionCall(JsonField.of(functionCall)) @JsonProperty("function_call") @ExcludeMissing @@ -4783,10 +4566,11 @@ private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } - fun toolCalls(toolCalls: List) = - toolCalls(JsonField.of(toolCalls)) + fun toolCalls(toolCalls: List) = toolCalls(JsonField.of(toolCalls)) @JsonProperty("tool_calls") @ExcludeMissing @@ -4794,47 +4578,42 @@ private constructor( this.toolCalls = toolCalls } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Assistant = - Assistant( - role, - content, - functionCall, - name, - toolCalls.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Assistant = Assistant( + role, + content, + functionCall, + name, + toolCalls.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && this.value == other.value + return other is Role && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -4857,29 +4636,22 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ASSISTANT -> Value.ASSISTANT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ASSISTANT -> Value.ASSISTANT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ASSISTANT -> Known.ASSISTANT - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = when (this) { + ASSISTANT -> Known.ASSISTANT + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(builder = FunctionCall.Builder::class) @NoAutoDetect - class FunctionCall - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { + class FunctionCall private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -4889,9 +4661,13 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments + @JsonProperty("arguments") + @ExcludeMissing + fun _arguments() = arguments - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing @@ -4899,39 +4675,37 @@ private constructor( fun validate(): FunctionCall = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionCall && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + return other is FunctionCall && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "FunctionCall{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -4942,8 +4716,7 @@ private constructor( private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(functionCall: FunctionCall) = apply { this.arguments = functionCall.arguments @@ -4963,40 +4736,40 @@ private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): FunctionCall = - FunctionCall( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): FunctionCall = FunctionCall( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } @JsonDeserialize(builder = ToolCall.Builder::class) @NoAutoDetect - class ToolCall - private constructor( - private val id: JsonField, - private val function: JsonField, - private val type: JsonField, - private val additionalProperties: Map, + class ToolCall private constructor( + private val id: JsonField, + private val function: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5009,11 +4782,17 @@ private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id - @JsonProperty("function") @ExcludeMissing fun _function() = function + @JsonProperty("function") + @ExcludeMissing + fun _function() = function - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type() = type @JsonAnyGetter @ExcludeMissing @@ -5021,42 +4800,40 @@ private constructor( fun validate(): ToolCall = apply { if (!validated) { - id() - function().validate() - type() - validated = true + id() + function().validate() + type() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ToolCall && - this.id == other.id && - this.function == other.function && - this.type == other.type && - this.additionalProperties == other.additionalProperties + return other is ToolCall && + this.id == other.id && + this.function == other.function && + this.type == other.type && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - function, - type, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + function, + type, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "ToolCall{id=$id, function=$function, type=$type, additionalProperties=$additionalProperties}" companion object { @@ -5068,8 +4845,7 @@ private constructor( private var id: JsonField = JsonMissing.of() private var function: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(toolCall: ToolCall) = apply { this.id = toolCall.id @@ -5082,7 +4858,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } + fun id(id: JsonField) = apply { + this.id = id + } fun function(function: Function) = function(JsonField.of(function)) @@ -5096,40 +4874,35 @@ private constructor( @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { + this.type = type + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): ToolCall = - ToolCall( - id, - function, - type, - additionalProperties.toUnmodifiable(), - ) + fun build(): ToolCall = ToolCall( + id, + function, + type, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function - private constructor( - private val arguments: JsonField, - private val name: JsonField, - private val additionalProperties: Map, - ) { + class Function private constructor(private val arguments: JsonField, private val name: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -5139,50 +4912,51 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("arguments") @ExcludeMissing fun _arguments() = arguments + @JsonProperty("arguments") + @ExcludeMissing + fun _arguments() = arguments - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties + fun _additionalProperties(): Map = additionalProperties fun validate(): Function = apply { if (!validated) { - arguments() - name() - validated = true + arguments() + name() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Function && - this.arguments == other.arguments && - this.name == other.name && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Function && + this.arguments == other.arguments && + this.name == other.name && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - arguments, - name, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + arguments, + name, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" + override fun toString() = "Function{arguments=$arguments, name=$name, additionalProperties=$additionalProperties}" companion object { @@ -5193,8 +4967,7 @@ private constructor( private var arguments: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(function: Function) = apply { this.arguments = function.arguments @@ -5202,8 +4975,7 @@ private constructor( additionalProperties(function.additionalProperties) } - fun arguments(arguments: String) = - arguments(JsonField.of(arguments)) + fun arguments(arguments: String) = arguments(JsonField.of(arguments)) @JsonProperty("arguments") @ExcludeMissing @@ -5215,11 +4987,11 @@ private constructor( @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } - fun additionalProperties( - additionalProperties: Map - ) = apply { + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) } @@ -5229,34 +5001,30 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Function = - Function( - arguments, - name, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = Function( + arguments, + name, + additionalProperties.toUnmodifiable(), + ) } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -5279,18 +5047,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> - throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + FUNCTION -> Known.FUNCTION + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -5299,12 +5064,12 @@ private constructor( @JsonDeserialize(builder = Tool.Builder::class) @NoAutoDetect - class Tool - private constructor( - private val content: JsonField, - private val role: JsonField, - private val toolCallId: JsonField, - private val additionalProperties: Map, + class Tool private constructor( + private val content: JsonField, + private val role: JsonField, + private val toolCallId: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5317,11 +5082,17 @@ private constructor( fun toolCallId(): String? = toolCallId.getNullable("tool_call_id") - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") + @ExcludeMissing + fun _content() = content - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") + @ExcludeMissing + fun _role() = role - @JsonProperty("tool_call_id") @ExcludeMissing fun _toolCallId() = toolCallId + @JsonProperty("tool_call_id") + @ExcludeMissing + fun _toolCallId() = toolCallId @JsonAnyGetter @ExcludeMissing @@ -5329,42 +5100,40 @@ private constructor( fun validate(): Tool = apply { if (!validated) { - content() - role() - toolCallId() - validated = true + content() + role() + toolCallId() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Tool && - this.content == other.content && - this.role == other.role && - this.toolCallId == other.toolCallId && - this.additionalProperties == other.additionalProperties + return other is Tool && + this.content == other.content && + this.role == other.role && + this.toolCallId == other.toolCallId && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - role, - toolCallId, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + content, + role, + toolCallId, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" + override fun toString() = "Tool{content=$content, role=$role, toolCallId=$toolCallId, additionalProperties=$additionalProperties}" companion object { @@ -5376,8 +5145,7 @@ private constructor( private var content: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() private var toolCallId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tool: Tool) = apply { this.content = tool.content @@ -5390,13 +5158,17 @@ private constructor( @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = apply { + this.role = role + } fun toolCallId(toolCallId: String) = toolCallId(JsonField.of(toolCallId)) @@ -5406,45 +5178,40 @@ private constructor( this.toolCallId = toolCallId } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Tool = - Tool( - content, - role, - toolCallId, - additionalProperties.toUnmodifiable(), - ) + fun build(): Tool = Tool( + content, + role, + toolCallId, + additionalProperties.toUnmodifiable(), + ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && this.value == other.value + return other is Role && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -5467,17 +5234,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TOOL -> Value.TOOL - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + TOOL -> Value.TOOL + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - TOOL -> Known.TOOL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = when (this) { + TOOL -> Known.TOOL + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -5485,12 +5250,12 @@ private constructor( @JsonDeserialize(builder = Function.Builder::class) @NoAutoDetect - class Function - private constructor( - private val content: JsonField, - private val name: JsonField, - private val role: JsonField, - private val additionalProperties: Map, + class Function private constructor( + private val content: JsonField, + private val name: JsonField, + private val role: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -5503,11 +5268,17 @@ private constructor( fun role(): Role = role.getRequired("role") - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") + @ExcludeMissing + fun _content() = content - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") + @ExcludeMissing + fun _role() = role @JsonAnyGetter @ExcludeMissing @@ -5515,42 +5286,40 @@ private constructor( fun validate(): Function = apply { if (!validated) { - content() - name() - role() - validated = true + content() + name() + role() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Function && - this.content == other.content && - this.name == other.name && - this.role == other.role && - this.additionalProperties == other.additionalProperties + return other is Function && + this.content == other.content && + this.name == other.name && + this.role == other.role && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - content, - name, - role, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + content, + name, + role, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" + override fun toString() = "Function{content=$content, name=$name, role=$role, additionalProperties=$additionalProperties}" companion object { @@ -5562,8 +5331,7 @@ private constructor( private var content: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var role: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(function: Function) = apply { this.content = function.content @@ -5576,59 +5344,60 @@ private constructor( @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } fun name(name: String) = name(JsonField.of(name)) @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } fun role(role: Role) = role(JsonField.of(role)) @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = apply { + this.role = role + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Function = - Function( - content, - name, - role, - additionalProperties.toUnmodifiable(), - ) + fun build(): Function = Function( + content, + name, + role, + additionalProperties.toUnmodifiable(), + ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && this.value == other.value + return other is Role && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -5651,17 +5420,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - FUNCTION -> Value.FUNCTION - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + FUNCTION -> Value.FUNCTION + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - FUNCTION -> Known.FUNCTION - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = when (this) { + FUNCTION -> Known.FUNCTION + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -5669,12 +5436,7 @@ private constructor( @JsonDeserialize(builder = Fallback.Builder::class) @NoAutoDetect - class Fallback - private constructor( - private val role: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { + class Fallback private constructor(private val role: JsonField, private val content: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -5684,9 +5446,13 @@ private constructor( fun content(): String? = content.getNullable("content") - @JsonProperty("role") @ExcludeMissing fun _role() = role + @JsonProperty("role") + @ExcludeMissing + fun _role() = role - @JsonProperty("content") @ExcludeMissing fun _content() = content + @JsonProperty("content") + @ExcludeMissing + fun _content() = content @JsonAnyGetter @ExcludeMissing @@ -5694,39 +5460,37 @@ private constructor( fun validate(): Fallback = apply { if (!validated) { - role() - content() - validated = true + role() + content() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Fallback && - this.role == other.role && - this.content == other.content && - this.additionalProperties == other.additionalProperties + return other is Fallback && + this.role == other.role && + this.content == other.content && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - role, - content, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + role, + content, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" + override fun toString() = "Fallback{role=$role, content=$content, additionalProperties=$additionalProperties}" companion object { @@ -5737,8 +5501,7 @@ private constructor( private var role: JsonField = JsonMissing.of() private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var additionalProperties: MutableMap = mutableMapOf() internal fun from(fallback: Fallback) = apply { this.role = fallback.role @@ -5750,52 +5513,51 @@ private constructor( @JsonProperty("role") @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } + fun role(role: JsonField) = apply { + this.role = role + } fun content(content: String) = content(JsonField.of(content)) @JsonProperty("content") @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } + fun content(content: JsonField) = apply { + this.content = content + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } @JsonAnySetter fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): Fallback = - Fallback( - role, - content, - additionalProperties.toUnmodifiable(), - ) + fun build(): Fallback = Fallback( + role, + content, + additionalProperties.toUnmodifiable(), + ) } - class Role - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Role @JsonCreator private constructor(private val value: JsonField, ) : Enum { @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Role && this.value == other.value + return other is Role && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -5818,37 +5580,33 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - MODEL -> Value.MODEL - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + MODEL -> Value.MODEL + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - MODEL -> Known.MODEL - else -> throw BraintrustInvalidDataException("Unknown Role: $value") - } + fun known(): Known = when (this) { + MODEL -> Known.MODEL + else -> throw BraintrustInvalidDataException("Unknown Role: $value") + } fun asString(): String = _value().asStringOrThrow() } } } - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Type @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Type && this.value == other.value + return other is Type && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -5871,17 +5629,15 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CHAT -> Value.CHAT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + CHAT -> Value.CHAT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - CHAT -> Known.CHAT - else -> throw BraintrustInvalidDataException("Unknown Type: $value") - } + fun known(): Known = when (this) { + CHAT -> Known.CHAT + else -> throw BraintrustInvalidDataException("Unknown Type: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -5889,10 +5645,7 @@ private constructor( @JsonDeserialize(builder = NullableVariant.Builder::class) @NoAutoDetect - class NullableVariant - private constructor( - private val additionalProperties: Map, - ) { + class NullableVariant private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -5904,26 +5657,26 @@ private constructor( fun validate(): NullableVariant = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is NullableVariant && - this.additionalProperties == other.additionalProperties + return other is NullableVariant && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "NullableVariant{additionalProperties=$additionalProperties}" @@ -5951,13 +5704,11 @@ private constructor( this.additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun build(): NullableVariant = - NullableVariant(additionalProperties.toUnmodifiable()) + fun build(): NullableVariant = NullableVariant(additionalProperties.toUnmodifiable()) } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt index 0d83f9f9..1c16194e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class PromptDeleteParams -constructor( - private val promptId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class PromptDeleteParams constructor( + private val promptId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun promptId(): String = promptId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptDeleteParams && - this.promptId == other.promptId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is PromptDeleteParams && + this.promptId == other.promptId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - promptId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + promptId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "PromptDeleteParams{promptId=$promptId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "PromptDeleteParams{promptId=$promptId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** Prompt id */ - fun promptId(promptId: String) = apply { this.promptId = promptId } + fun promptId(promptId: String) = apply { + this.promptId = promptId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): PromptDeleteParams = - PromptDeleteParams( - checkNotNull(promptId) { "`promptId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): PromptDeleteParams = PromptDeleteParams( + checkNotNull(promptId) { + "`promptId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt index bd1faa81..b72266e8 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPage.kt @@ -2,97 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.services.blocking.PromptService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class PromptListPage -private constructor( - private val promptService: PromptService, - private val params: PromptListParams, - private val response: Response, -) { +class PromptListPage private constructor(private val promptService: PromptService, private val params: PromptListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptListPage && - this.promptService == other.promptService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is PromptListPage && + this.promptService == other.promptService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - promptService, - params, - response, - ) + return Objects.hash( + promptService, + params, + response, + ) } - override fun toString() = - "PromptListPage{promptService=$promptService, params=$params, response=$response}" + override fun toString() = "PromptListPage{promptService=$promptService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): PromptListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - PromptListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - PromptListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + PromptListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + PromptListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): PromptListPage? { - return getNextPageParams()?.let { promptService.list(it) } + return getNextPageParams()?.let { + promptService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(promptService: PromptService, params: PromptListParams, response: Response) = - PromptListPage( - promptService, - params, - response, - ) + fun of(promptService: PromptService, params: PromptListParams, response: Response) = PromptListPage( + promptService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -100,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "PromptListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "PromptListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -153,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: PromptListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: PromptListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt index e9a9c568..b3da17b2 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListPageAsync.kt @@ -2,99 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.PromptServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Prompt +import com.braintrustdata.api.services.async.PromptServiceAsync -class PromptListPageAsync -private constructor( - private val promptService: PromptServiceAsync, - private val params: PromptListParams, - private val response: Response, -) { +class PromptListPageAsync private constructor(private val promptService: PromptServiceAsync, private val params: PromptListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptListPageAsync && - this.promptService == other.promptService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is PromptListPageAsync && + this.promptService == other.promptService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - promptService, - params, - response, - ) + return Objects.hash( + promptService, + params, + response, + ) } - override fun toString() = - "PromptListPageAsync{promptService=$promptService, params=$params, response=$response}" + override fun toString() = "PromptListPageAsync{promptService=$promptService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): PromptListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - PromptListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - PromptListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + PromptListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + PromptListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): PromptListPageAsync? { - return getNextPageParams()?.let { promptService.list(it) } + return getNextPageParams()?.let { + promptService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(promptService: PromptServiceAsync, params: PromptListParams, response: Response) = - PromptListPageAsync( - promptService, - params, - response, - ) + fun of(promptService: PromptServiceAsync, params: PromptListParams, response: Response) = PromptListPageAsync( + promptService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -102,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "PromptListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "PromptListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -155,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: PromptListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: PromptListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt index 4ed7664b..0b0bb056 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptListParams.kt @@ -2,37 +2,54 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class PromptListParams constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val projectId: String?, + private val projectName: String?, + private val promptName: String?, + private val slug: String?, + private val startingAfter: String?, + private val version: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class PromptListParams -constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val projectId: String?, - private val projectName: String?, - private val promptName: String?, - private val slug: String?, - private val startingAfter: String?, - private val version: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun endingBefore(): String? = endingBefore @@ -56,19 +73,39 @@ constructor( fun version(): String? = version internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.projectId?.let { params.put("project_id", listOf(it.toString())) } - this.projectName?.let { params.put("project_name", listOf(it.toString())) } - this.promptName?.let { params.put("prompt_name", listOf(it.toString())) } - this.slug?.let { params.put("slug", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - this.version?.let { params.put("version", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.projectId?.let { + params.put("project_id", listOf(it.toString())) + } + this.projectName?.let { + params.put("project_name", listOf(it.toString())) + } + this.promptName?.let { + params.put("prompt_name", listOf(it.toString())) + } + this.slug?.let { + params.put("slug", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + this.version?.let { + params.put("version", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -78,44 +115,43 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.projectId == other.projectId && - this.projectName == other.projectName && - this.promptName == other.promptName && - this.slug == other.slug && - this.startingAfter == other.startingAfter && - this.version == other.version && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is PromptListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.projectId == other.projectId && + this.projectName == other.projectName && + this.promptName == other.promptName && + this.slug == other.slug && + this.startingAfter == other.startingAfter && + this.version == other.version && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - promptName, - slug, - startingAfter, - version, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + promptName, + slug, + startingAfter, + version, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "PromptListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, projectId=$projectId, projectName=$projectName, promptName=$promptName, slug=$slug, startingAfter=$startingAfter, version=$version, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -158,64 +194,88 @@ 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Project id */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** 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 prompt to search for */ - fun promptName(promptName: String) = apply { this.promptName = promptName } + fun promptName(promptName: String) = apply { + this.promptName = promptName + } /** Retrieve prompt with a specific slug */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: String) = apply { + this.slug = slug + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } /** * 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -255,86 +315,81 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): PromptListParams = - PromptListParams( - endingBefore, - ids, - limit, - orgName, - projectId, - projectName, - promptName, - slug, - startingAfter, - version, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): PromptListParams = PromptListParams( + endingBefore, + ids, + limit, + orgName, + projectId, + projectName, + promptName, + slug, + startingAfter, + version, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -351,38 +406,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt index e0db4317..07fb6b5c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptReplaceParams.kt @@ -2,33 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class PromptReplaceParams constructor( + private val name: String, + private val projectId: String, + private val slug: String, + private val description: String?, + private val functionType: FunctionType?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class PromptReplaceParams -constructor( - private val name: String, - private val projectId: String, - private val slug: String, - private val description: String?, - private val functionType: FunctionType?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -46,16 +65,16 @@ constructor( fun tags(): List? = tags internal fun getBody(): PromptReplaceBody { - return PromptReplaceBody( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalBodyProperties, - ) + return PromptReplaceBody( + name, + projectId, + slug, + description, + functionType, + promptData, + tags, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -64,39 +83,46 @@ constructor( @JsonDeserialize(builder = PromptReplaceBody.Builder::class) @NoAutoDetect - class PromptReplaceBody - internal constructor( - private val name: String?, - private val projectId: String?, - private val slug: String?, - private val description: String?, - private val functionType: FunctionType?, - private val promptData: PromptData?, - private val tags: List?, - private val additionalProperties: Map, + class PromptReplaceBody internal constructor( + private val name: String?, + private val projectId: String?, + private val slug: String?, + private val description: String?, + private val functionType: FunctionType?, + private val promptData: PromptData?, + private val tags: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Unique identifier for the project that the prompt belongs under */ - @JsonProperty("project_id") fun projectId(): String? = projectId + @JsonProperty("project_id") + fun projectId(): String? = projectId /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(): String? = slug + @JsonProperty("slug") + fun slug(): String? = slug /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description - @JsonProperty("function_type") fun functionType(): FunctionType? = functionType + @JsonProperty("function_type") + fun functionType(): FunctionType? = functionType /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + fun promptData(): PromptData? = promptData /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") + fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -105,40 +131,38 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptReplaceBody && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptReplaceBody && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.functionType == other.functionType && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + projectId, + slug, + description, + functionType, + promptData, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "PromptReplaceBody{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalProperties=$additionalProperties}" companion object { @@ -168,18 +192,28 @@ constructor( } /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ @JsonProperty("project_id") - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } + @JsonProperty("slug") + fun slug(slug: String) = apply { + this.slug = slug + } /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } @JsonProperty("function_type") fun functionType(functionType: FunctionType) = apply { @@ -188,10 +222,15 @@ constructor( /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + @JsonProperty("tags") + fun tags(tags: List) = apply { + this.tags = tags + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -207,17 +246,22 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptReplaceBody = - PromptReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionType, - promptData, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptReplaceBody = PromptReplaceBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + checkNotNull(slug) { + "`slug` is required but was not set" + }, + description, + functionType, + promptData, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -228,40 +272,39 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptReplaceParams && - this.name == other.name && - this.projectId == other.projectId && - this.slug == other.slug && - this.description == other.description && - this.functionType == other.functionType && - this.promptData == other.promptData && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is PromptReplaceParams && + this.name == other.name && + this.projectId == other.projectId && + this.slug == other.slug && + this.description == other.description && + this.functionType == other.functionType && + this.promptData == other.promptData && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - projectId, - slug, - description, - functionType, - promptData, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + projectId, + slug, + description, + functionType, + promptData, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "PromptReplaceParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "PromptReplaceParams{name=$name, projectId=$projectId, slug=$slug, description=$description, functionType=$functionType, promptData=$promptData, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -298,21 +341,33 @@ constructor( } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Unique identifier for the project that the prompt belongs under */ - fun projectId(projectId: String) = apply { this.projectId = projectId } + fun projectId(projectId: String) = apply { + this.projectId = projectId + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: String) = apply { + this.slug = slug + } /** Textual description of the prompt */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } - fun functionType(functionType: FunctionType) = apply { this.functionType = functionType } + fun functionType(functionType: FunctionType) = apply { + this.functionType = functionType + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -321,7 +376,9 @@ constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun addTag(tag: String) = apply { + this.tags.add(tag) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -361,7 +418,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -372,40 +431,42 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): PromptReplaceParams = - PromptReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - description, - functionType, - promptData, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): PromptReplaceParams = PromptReplaceParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(projectId) { + "`projectId` is required but was not set" + }, + checkNotNull(slug) { + "`slug` is required but was not set" + }, + description, + functionType, + promptData, + if(tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class FunctionType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class FunctionType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FunctionType && this.value == other.value + return other is FunctionType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -436,21 +497,19 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - TASK -> Value.TASK - LLM -> Value.LLM - SCORER -> Value.SCORER - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + TASK -> Value.TASK + LLM -> Value.LLM + SCORER -> Value.SCORER + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - TASK -> Known.TASK - LLM -> Known.LLM - SCORER -> Known.SCORER - else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") - } + fun known(): Known = when (this) { + TASK -> Known.TASK + LLM -> Known.LLM + SCORER -> Known.SCORER + else -> throw BraintrustInvalidDataException("Unknown FunctionType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt index b5fd935e..97315a50 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class PromptRetrieveParams -constructor( - private val promptId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class PromptRetrieveParams constructor(private val promptId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun promptId(): String = promptId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptRetrieveParams && - this.promptId == other.promptId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is PromptRetrieveParams && + this.promptId == other.promptId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - promptId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + promptId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "PromptRetrieveParams{promptId=$promptId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "PromptRetrieveParams{promptId=$promptId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** Prompt id */ - fun promptId(promptId: String) = apply { this.promptId = promptId } + fun promptId(promptId: String) = apply { + this.promptId = promptId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): PromptRetrieveParams = - PromptRetrieveParams( - checkNotNull(promptId) { "`promptId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): PromptRetrieveParams = PromptRetrieveParams( + checkNotNull(promptId) { + "`promptId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt index f0e9a758..41d3f6d9 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/PromptUpdateParams.kt @@ -2,28 +2,51 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class PromptUpdateParams constructor( + private val promptId: String, + private val description: String?, + private val name: String?, + private val promptData: PromptData?, + private val slug: String?, + private val tags: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class PromptUpdateParams -constructor( - private val promptId: String, - private val description: String?, - private val name: String?, - private val promptData: PromptData?, - private val slug: String?, - private val tags: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun promptId(): String = promptId @@ -39,14 +62,14 @@ constructor( fun tags(): List? = tags internal fun getBody(): PromptUpdateBody { - return PromptUpdateBody( - description, - name, - promptData, - slug, - tags, - additionalBodyProperties, - ) + return PromptUpdateBody( + description, + name, + promptData, + slug, + tags, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -54,40 +77,45 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> promptId - else -> "" - } + return when (index) { + 0 -> promptId + else -> "" + } } @JsonDeserialize(builder = PromptUpdateBody.Builder::class) @NoAutoDetect - class PromptUpdateBody - internal constructor( - private val description: String?, - private val name: String?, - private val promptData: PromptData?, - private val slug: String?, - private val tags: List?, - private val additionalProperties: Map, + class PromptUpdateBody internal constructor( + private val description: String?, + private val name: String?, + private val promptData: PromptData?, + private val slug: String?, + private val tags: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Textual description of the prompt */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description /** Name of the prompt */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** The prompt, model, and its parameters */ - @JsonProperty("prompt_data") fun promptData(): PromptData? = promptData + @JsonProperty("prompt_data") + fun promptData(): PromptData? = promptData /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(): String? = slug + @JsonProperty("slug") + fun slug(): String? = slug /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(): List? = tags + @JsonProperty("tags") + fun tags(): List? = tags @JsonAnyGetter @ExcludeMissing @@ -96,36 +124,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptUpdateBody && - this.description == other.description && - this.name == other.name && - this.promptData == other.promptData && - this.slug == other.slug && - this.tags == other.tags && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is PromptUpdateBody && + this.description == other.description && + this.name == other.name && + this.promptData == other.promptData && + this.slug == other.slug && + this.tags == other.tags && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - description, - name, - promptData, - slug, - tags, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + description, + name, + promptData, + slug, + tags, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" + override fun toString() = "PromptUpdateBody{description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalProperties=$additionalProperties}" companion object { @@ -152,20 +178,33 @@ constructor( /** Textual description of the prompt */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Name of the prompt */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** The prompt, model, and its parameters */ @JsonProperty("prompt_data") - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** Unique identifier for the prompt */ - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } + @JsonProperty("slug") + fun slug(slug: String) = apply { + this.slug = slug + } /** A list of tags for the prompt */ - @JsonProperty("tags") fun tags(tags: List) = apply { this.tags = tags } + @JsonProperty("tags") + fun tags(tags: List) = apply { + this.tags = tags + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -181,15 +220,14 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): PromptUpdateBody = - PromptUpdateBody( - description, - name, - promptData, - slug, - tags?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): PromptUpdateBody = PromptUpdateBody( + description, + name, + promptData, + slug, + tags?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -200,38 +238,37 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PromptUpdateParams && - this.promptId == other.promptId && - this.description == other.description && - this.name == other.name && - this.promptData == other.promptData && - this.slug == other.slug && - this.tags == other.tags && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is PromptUpdateParams && + this.promptId == other.promptId && + this.description == other.description && + this.name == other.name && + this.promptData == other.promptData && + this.slug == other.slug && + this.tags == other.tags && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - promptId, - description, - name, - promptData, - slug, - tags, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + promptId, + description, + name, + promptData, + slug, + tags, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "PromptUpdateParams{promptId=$promptId, description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "PromptUpdateParams{promptId=$promptId, description=$description, name=$name, promptData=$promptData, slug=$slug, tags=$tags, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -266,19 +303,29 @@ constructor( } /** 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 { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Name of the prompt */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** The prompt, model, and its parameters */ - fun promptData(promptData: PromptData) = apply { this.promptData = promptData } + fun promptData(promptData: PromptData) = apply { + this.promptData = promptData + } /** Unique identifier for the prompt */ - fun slug(slug: String) = apply { this.slug = slug } + fun slug(slug: String) = apply { + this.slug = slug + } /** A list of tags for the prompt */ fun tags(tags: List) = apply { @@ -287,7 +334,9 @@ constructor( } /** A list of tags for the prompt */ - fun addTag(tag: String) = apply { this.tags.add(tag) } + fun addTag(tag: String) = apply { + this.tags.add(tag) + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -327,7 +376,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -338,22 +389,22 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): PromptUpdateParams = - PromptUpdateParams( - checkNotNull(promptId) { "`promptId` is required but was not set" }, - description, - name, - promptData, - slug, - if (tags.size == 0) null else tags.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): PromptUpdateParams = PromptUpdateParams( + checkNotNull(promptId) { + "`promptId` is required but was not set" + }, + description, + name, + promptData, + slug, + if(tags.size == 0) null else tags.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt index d8ff8d63..e7973df1 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RepoInfo.kt @@ -2,33 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** Metadata about the state of the repo when the experiment was created */ @JsonDeserialize(builder = RepoInfo.Builder::class) @NoAutoDetect -class RepoInfo -private constructor( - private val commit: JsonField, - private val branch: JsonField, - private val tag: JsonField, - private val dirty: JsonField, - private val authorName: JsonField, - private val authorEmail: JsonField, - private val commitMessage: JsonField, - private val commitTime: JsonField, - private val gitDiff: JsonField, - private val additionalProperties: Map, +class RepoInfo private constructor( + private val commit: JsonField, + private val branch: JsonField, + private val tag: JsonField, + private val dirty: JsonField, + private val authorName: JsonField, + private val authorEmail: JsonField, + private val commitMessage: JsonField, + private val commitTime: JsonField, + private val gitDiff: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -60,40 +79,58 @@ private constructor( fun commitTime(): String? = commitTime.getNullable("commit_time") /** - * 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(): String? = gitDiff.getNullable("git_diff") /** SHA of most recent commit */ - @JsonProperty("commit") @ExcludeMissing fun _commit() = commit + @JsonProperty("commit") + @ExcludeMissing + fun _commit() = commit /** Name of the branch the most recent commit belongs to */ - @JsonProperty("branch") @ExcludeMissing fun _branch() = branch + @JsonProperty("branch") + @ExcludeMissing + fun _branch() = branch /** Name of the tag on the most recent commit */ - @JsonProperty("tag") @ExcludeMissing fun _tag() = tag + @JsonProperty("tag") + @ExcludeMissing + fun _tag() = tag /** Whether or not the repo had uncommitted changes when snapshotted */ - @JsonProperty("dirty") @ExcludeMissing fun _dirty() = dirty + @JsonProperty("dirty") + @ExcludeMissing + fun _dirty() = dirty /** Name of the author of the most recent commit */ - @JsonProperty("author_name") @ExcludeMissing fun _authorName() = authorName + @JsonProperty("author_name") + @ExcludeMissing + fun _authorName() = authorName /** Email of the author of the most recent commit */ - @JsonProperty("author_email") @ExcludeMissing fun _authorEmail() = authorEmail + @JsonProperty("author_email") + @ExcludeMissing + fun _authorEmail() = authorEmail /** Most recent commit message */ - @JsonProperty("commit_message") @ExcludeMissing fun _commitMessage() = commitMessage + @JsonProperty("commit_message") + @ExcludeMissing + fun _commitMessage() = commitMessage /** Time of the most recent commit */ - @JsonProperty("commit_time") @ExcludeMissing fun _commitTime() = commitTime + @JsonProperty("commit_time") + @ExcludeMissing + fun _commitTime() = commitTime /** - * 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() = gitDiff + @JsonProperty("git_diff") + @ExcludeMissing + fun _gitDiff() = gitDiff @JsonAnyGetter @ExcludeMissing @@ -101,60 +138,58 @@ private constructor( fun validate(): RepoInfo = apply { if (!validated) { - commit() - branch() - tag() - dirty() - authorName() - authorEmail() - commitMessage() - commitTime() - gitDiff() - validated = true + commit() + branch() + tag() + dirty() + authorName() + authorEmail() + commitMessage() + commitTime() + gitDiff() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RepoInfo && - this.commit == other.commit && - this.branch == other.branch && - this.tag == other.tag && - this.dirty == other.dirty && - this.authorName == other.authorName && - this.authorEmail == other.authorEmail && - this.commitMessage == other.commitMessage && - this.commitTime == other.commitTime && - this.gitDiff == other.gitDiff && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RepoInfo && + this.commit == other.commit && + this.branch == other.branch && + this.tag == other.tag && + this.dirty == other.dirty && + this.authorName == other.authorName && + this.authorEmail == other.authorEmail && + this.commitMessage == other.commitMessage && + this.commitTime == other.commitTime && + this.gitDiff == other.gitDiff && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + commit, + branch, + tag, + dirty, + authorName, + authorEmail, + commitMessage, + commitTime, + gitDiff, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" + override fun toString() = "RepoInfo{commit=$commit, branch=$branch, tag=$tag, dirty=$dirty, authorName=$authorName, authorEmail=$authorEmail, commitMessage=$commitMessage, commitTime=$commitTime, gitDiff=$gitDiff, additionalProperties=$additionalProperties}" companion object { @@ -193,7 +228,9 @@ private constructor( /** SHA of most recent commit */ @JsonProperty("commit") @ExcludeMissing - fun commit(commit: JsonField) = apply { this.commit = commit } + fun commit(commit: JsonField) = apply { + this.commit = commit + } /** Name of the branch the most recent commit belongs to */ fun branch(branch: String) = branch(JsonField.of(branch)) @@ -201,7 +238,9 @@ private constructor( /** Name of the branch the most recent commit belongs to */ @JsonProperty("branch") @ExcludeMissing - fun branch(branch: JsonField) = apply { this.branch = branch } + fun branch(branch: JsonField) = apply { + this.branch = branch + } /** Name of the tag on the most recent commit */ fun tag(tag: String) = tag(JsonField.of(tag)) @@ -209,7 +248,9 @@ private constructor( /** Name of the tag on the most recent commit */ @JsonProperty("tag") @ExcludeMissing - fun tag(tag: JsonField) = apply { this.tag = tag } + fun tag(tag: JsonField) = apply { + this.tag = tag + } /** Whether or not the repo had uncommitted changes when snapshotted */ fun dirty(dirty: Boolean) = dirty(JsonField.of(dirty)) @@ -217,7 +258,9 @@ private constructor( /** Whether or not the repo had uncommitted changes when snapshotted */ @JsonProperty("dirty") @ExcludeMissing - fun dirty(dirty: JsonField) = apply { this.dirty = dirty } + fun dirty(dirty: JsonField) = apply { + this.dirty = dirty + } /** Name of the author of the most recent commit */ fun authorName(authorName: String) = authorName(JsonField.of(authorName)) @@ -225,7 +268,9 @@ private constructor( /** Name of the author of the most recent commit */ @JsonProperty("author_name") @ExcludeMissing - fun authorName(authorName: JsonField) = apply { this.authorName = authorName } + fun authorName(authorName: JsonField) = apply { + this.authorName = authorName + } /** Email of the author of the most recent commit */ fun authorEmail(authorEmail: String) = authorEmail(JsonField.of(authorEmail)) @@ -233,7 +278,9 @@ private constructor( /** Email of the author of the most recent commit */ @JsonProperty("author_email") @ExcludeMissing - fun authorEmail(authorEmail: JsonField) = apply { this.authorEmail = authorEmail } + fun authorEmail(authorEmail: JsonField) = apply { + this.authorEmail = authorEmail + } /** Most recent commit message */ fun commitMessage(commitMessage: String) = commitMessage(JsonField.of(commitMessage)) @@ -251,21 +298,25 @@ private constructor( /** Time of the most recent commit */ @JsonProperty("commit_time") @ExcludeMissing - fun commitTime(commitTime: JsonField) = apply { this.commitTime = commitTime } + fun commitTime(commitTime: JsonField) = apply { + this.commitTime = commitTime + } /** - * 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.of(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. */ @JsonProperty("git_diff") @ExcludeMissing - fun gitDiff(gitDiff: JsonField) = apply { this.gitDiff = gitDiff } + fun gitDiff(gitDiff: JsonField) = apply { + this.gitDiff = gitDiff + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -281,18 +332,17 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RepoInfo = - RepoInfo( - commit, - branch, - tag, - dirty, - authorName, - authorEmail, - commitMessage, - commitTime, - gitDiff, - additionalProperties.toUnmodifiable(), - ) + fun build(): RepoInfo = RepoInfo( + commit, + branch, + tag, + dirty, + authorName, + authorEmail, + commitMessage, + commitTime, + gitDiff, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt index df518f07..12612b10 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/Role.kt @@ -2,41 +2,57 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** * 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 */ @JsonDeserialize(builder = Role.Builder::class) @NoAutoDetect -class Role -private constructor( - private val id: JsonField, - private val orgId: JsonField, - private val userId: JsonField, - private val created: JsonField, - private val name: JsonField, - private val description: JsonField, - private val deletedAt: JsonField, - private val memberPermissions: JsonField>, - private val memberRoles: JsonField>, - private val additionalProperties: Map, +class Role private constructor( + private val id: JsonField, + private val orgId: JsonField, + private val userId: JsonField, + private val created: JsonField, + private val name: JsonField, + private val description: JsonField, + private val deletedAt: JsonField, + private val memberPermissions: JsonField>, + private val memberRoles: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -49,8 +65,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 */ @@ -72,55 +88,72 @@ private constructor( fun deletedAt(): OffsetDateTime? = deletedAt.getNullable("deleted_at") /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(): List? = - memberPermissions.getNullable("member_permissions") + fun memberPermissions(): List? = 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(): List? = memberRoles.getNullable("member_roles") /** Unique identifier for the role */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by any - * other role, but cannot be edited. + * A null org_id indicates a system role, which may be assigned to anybody and + * inherited by any other role, but cannot be edited. * * It is forbidden to change the org after creating a role */ - @JsonProperty("org_id") @ExcludeMissing fun _orgId() = orgId + @JsonProperty("org_id") + @ExcludeMissing + fun _orgId() = orgId /** Identifies the user who created the role */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId /** Date of role creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** Name of the role */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Textual description of the role */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description() = description /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt() = deletedAt /** (permission, restrict_object_type) tuples which belong to this role */ - @JsonProperty("member_permissions") @ExcludeMissing fun _memberPermissions() = memberPermissions + @JsonProperty("member_permissions") + @ExcludeMissing + fun _memberPermissions() = memberPermissions /** * Ids of the roles this role inherits from * - * An inheriting role has all the permissions contained in its member roles, as well as all of - * their inherited permissions + * An inheriting role has all the permissions contained in its member roles, as + * well as all of their inherited permissions */ - @JsonProperty("member_roles") @ExcludeMissing fun _memberRoles() = memberRoles + @JsonProperty("member_roles") + @ExcludeMissing + fun _memberRoles() = memberRoles @JsonAnyGetter @ExcludeMissing @@ -128,60 +161,58 @@ private constructor( fun validate(): Role = apply { if (!validated) { - id() - orgId() - userId() - created() - name() - description() - deletedAt() - memberPermissions()?.forEach { it.validate() } - memberRoles() - validated = true + id() + orgId() + userId() + created() + name() + description() + deletedAt() + memberPermissions()?.forEach { it.validate() } + memberRoles() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Role && - this.id == other.id && - this.orgId == other.orgId && - this.userId == other.userId && - this.created == other.created && - this.name == other.name && - this.description == other.description && - this.deletedAt == other.deletedAt && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is Role && + this.id == other.id && + this.orgId == other.orgId && + this.userId == other.userId && + this.created == other.created && + this.name == other.name && + this.description == other.description && + this.deletedAt == other.deletedAt && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - orgId, - userId, - created, - name, - description, - deletedAt, - memberPermissions, - memberRoles, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + orgId, + userId, + created, + name, + description, + deletedAt, + memberPermissions, + memberRoles, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "Role{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberPermissions=$memberPermissions, memberRoles=$memberRoles, additionalProperties=$additionalProperties}" + override fun toString() = "Role{id=$id, orgId=$orgId, userId=$userId, created=$created, name=$name, description=$description, deletedAt=$deletedAt, memberPermissions=$memberPermissions, memberRoles=$memberRoles, additionalProperties=$additionalProperties}" companion object { @@ -218,13 +249,17 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the role */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** * Unique id for the organization that the role belongs under * - * A null org_id indicates a system role, which may be assigned to anybody and inherited by - * any other role, but cannot be edited. + * 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 */ @@ -233,14 +268,16 @@ 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(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.of(userId)) @@ -248,7 +285,9 @@ private constructor( /** Identifies the user who created the role */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } /** Date of role creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -256,7 +295,9 @@ private constructor( /** Date of role creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** Name of the role */ fun name(name: String) = name(JsonField.of(name)) @@ -264,7 +305,9 @@ private constructor( /** Name of the role */ @JsonProperty("name") @ExcludeMissing - 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.of(description)) @@ -272,7 +315,9 @@ private constructor( /** Textual description of the role */ @JsonProperty("description") @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) @@ -280,11 +325,12 @@ private constructor( /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } /** (permission, restrict_object_type) tuples which belong to this role */ - fun memberPermissions(memberPermissions: List) = - memberPermissions(JsonField.of(memberPermissions)) + fun memberPermissions(memberPermissions: List) = memberPermissions(JsonField.of(memberPermissions)) /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -296,16 +342,16 @@ 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(memberRoles: List) = memberRoles(JsonField.of(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 */ @JsonProperty("member_roles") @ExcludeMissing @@ -327,29 +373,23 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Role = - Role( - id, - orgId, - userId, - created, - name, - description, - deletedAt, - memberPermissions.map { it.toUnmodifiable() }, - memberRoles.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): Role = Role( + id, + orgId, + userId, + created, + name, + description, + deletedAt, + memberPermissions.map { it.toUnmodifiable() }, + memberRoles.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = MemberPermission.Builder::class) @NoAutoDetect - class MemberPermission - private constructor( - private val permission: JsonField, - private val restrictObjectType: JsonField, - private val additionalProperties: Map, - ) { + class MemberPermission private constructor(private val permission: JsonField, private val restrictObjectType: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -358,20 +398,23 @@ private constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ fun permission(): Permission? = permission.getNullable("permission") /** The object type that the ACL applies to */ - fun restrictObjectType(): RestrictObjectType? = - restrictObjectType.getNullable("restrict_object_type") + fun restrictObjectType(): RestrictObjectType? = 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 fun _permission() = permission + @JsonProperty("permission") + @ExcludeMissing + fun _permission() = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -384,39 +427,37 @@ private constructor( fun validate(): MemberPermission = apply { if (!validated) { - permission() - restrictObjectType() - validated = true + permission() + restrictObjectType() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is MemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" companion object { @@ -438,16 +479,16 @@ private constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * 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 */ @JsonProperty("permission") @ExcludeMissing @@ -456,8 +497,7 @@ private constructor( } /** The object type that the ACL applies to */ - fun restrictObjectType(restrictObjectType: RestrictObjectType) = - restrictObjectType(JsonField.of(restrictObjectType)) + fun restrictObjectType(restrictObjectType: RestrictObjectType) = restrictObjectType(JsonField.of(restrictObjectType)) /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -480,28 +520,25 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): MemberPermission = - MemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): MemberPermission = MemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) } - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && this.value == other.value + return other is Permission && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -552,49 +589,45 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && this.value == other.value + return other is RestrictObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -657,38 +690,35 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt index 58ac5679..1488f466 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleCreateParams.kt @@ -2,31 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class RoleCreateParams constructor( + private val name: String, + private val description: String?, + private val memberPermissions: List?, + private val memberRoles: List?, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class RoleCreateParams -constructor( - private val name: String, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -40,14 +59,14 @@ constructor( fun orgName(): String? = orgName internal fun getBody(): RoleCreateBody { - return RoleCreateBody( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalBodyProperties, - ) + return RoleCreateBody( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -56,23 +75,25 @@ constructor( @JsonDeserialize(builder = RoleCreateBody.Builder::class) @NoAutoDetect - class RoleCreateBody - internal constructor( - private val name: String?, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, - private val additionalProperties: Map, + class RoleCreateBody internal constructor( + private val name: String?, + private val description: String?, + private val memberPermissions: List?, + private val memberRoles: List?, + private val orgName: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the role */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Textual description of the role */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -81,17 +102,19 @@ 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") fun memberRoles(): List? = memberRoles + @JsonProperty("member_roles") + fun memberRoles(): List? = 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") fun orgName(): String? = orgName + @JsonProperty("org_name") + fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -100,36 +123,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleCreateBody && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RoleCreateBody && + this.name == other.name && + this.description == other.description && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "RoleCreateBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { @@ -155,11 +176,16 @@ constructor( } /** Name of the role */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Textual description of the role */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -170,19 +196,23 @@ 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") - fun memberRoles(memberRoles: List) = apply { this.memberRoles = memberRoles } + fun memberRoles(memberRoles: List) = apply { + this.memberRoles = 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") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -198,15 +228,16 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RoleCreateBody = - RoleCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - description, - memberPermissions?.toUnmodifiable(), - memberRoles?.toUnmodifiable(), - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): RoleCreateBody = RoleCreateBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + description, + memberPermissions?.toUnmodifiable(), + memberRoles?.toUnmodifiable(), + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -217,36 +248,35 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleCreateParams && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is RoleCreateParams && + this.name == other.name && + this.description == other.description && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "RoleCreateParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "RoleCreateParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -279,10 +309,14 @@ constructor( } /** Name of the role */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Textual description of the role */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: List) = apply { @@ -298,8 +332,8 @@ 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(memberRoles: List) = apply { this.memberRoles.clear() @@ -309,17 +343,21 @@ 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 addMemberRole(memberRole: String) = apply { this.memberRoles.add(memberRole) } + fun addMemberRole(memberRole: String) = apply { + this.memberRoles.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) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -359,7 +397,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -370,41 +410,38 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): RoleCreateParams = - RoleCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - description, - if (memberPermissions.size == 0) null else memberPermissions.toUnmodifiable(), - if (memberRoles.size == 0) null else memberRoles.toUnmodifiable(), - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): RoleCreateParams = RoleCreateParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + description, + if(memberPermissions.size == 0) null else memberPermissions.toUnmodifiable(), + if(memberRoles.size == 0) null else memberRoles.toUnmodifiable(), + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = MemberPermission.Builder::class) @NoAutoDetect - class MemberPermission - private constructor( - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val additionalProperties: Map, - ) { + class MemberPermission private constructor(private val permission: Permission?, private val restrictObjectType: RestrictObjectType?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** * 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") fun permission(): Permission? = permission + @JsonProperty("permission") + fun permission(): Permission? = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -417,30 +454,28 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is MemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" companion object { @@ -462,11 +497,13 @@ constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Permission) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -488,28 +525,25 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): MemberPermission = - MemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): MemberPermission = MemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) } - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && this.value == other.value + return other is Permission && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -560,49 +594,45 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && this.value == other.value + return other is RestrictObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -665,38 +695,35 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt index c9b13625..153eb12c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleDeleteParams.kt @@ -2,24 +2,52 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class RoleDeleteParams -constructor( - private val roleId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, +class RoleDeleteParams constructor( + private val roleId: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, + ) { fun roleId(): String = roleId internal fun getBody(): Map? { - return additionalBodyProperties.ifEmpty { null } + return additionalBodyProperties.ifEmpty { null } } internal fun getQueryParams(): Map> = additionalQueryParams @@ -27,10 +55,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -40,28 +68,27 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleDeleteParams && - this.roleId == other.roleId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is RoleDeleteParams && + this.roleId == other.roleId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - roleId, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + roleId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "RoleDeleteParams{roleId=$roleId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "RoleDeleteParams{roleId=$roleId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -86,7 +113,9 @@ constructor( } /** Role id */ - fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String) = apply { + this.roleId = roleId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -126,7 +155,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -137,17 +168,17 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun build(): RoleDeleteParams = - RoleDeleteParams( - checkNotNull(roleId) { "`roleId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): RoleDeleteParams = RoleDeleteParams( + checkNotNull(roleId) { + "`roleId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt index d56088df..6e579b8a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPage.kt @@ -2,97 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Role import com.braintrustdata.api.services.blocking.RoleService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class RoleListPage -private constructor( - private val roleService: RoleService, - private val params: RoleListParams, - private val response: Response, -) { +class RoleListPage private constructor(private val roleService: RoleService, private val params: RoleListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleListPage && - this.roleService == other.roleService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is RoleListPage && + this.roleService == other.roleService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - roleService, - params, - response, - ) + return Objects.hash( + roleService, + params, + response, + ) } - override fun toString() = - "RoleListPage{roleService=$roleService, params=$params, response=$response}" + override fun toString() = "RoleListPage{roleService=$roleService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): RoleListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - RoleListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - RoleListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + RoleListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + RoleListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): RoleListPage? { - return getNextPageParams()?.let { roleService.list(it) } + return getNextPageParams()?.let { + roleService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(roleService: RoleService, params: RoleListParams, response: Response) = - RoleListPage( - roleService, - params, - response, - ) + fun of(roleService: RoleService, params: RoleListParams, response: Response) = RoleListPage( + roleService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -100,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "RoleListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "RoleListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -153,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: RoleListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: RoleListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt index a94269b7..c5893d2a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListPageAsync.kt @@ -2,99 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.RoleServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.Role +import com.braintrustdata.api.services.async.RoleServiceAsync -class RoleListPageAsync -private constructor( - private val roleService: RoleServiceAsync, - private val params: RoleListParams, - private val response: Response, -) { +class RoleListPageAsync private constructor(private val roleService: RoleServiceAsync, private val params: RoleListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleListPageAsync && - this.roleService == other.roleService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is RoleListPageAsync && + this.roleService == other.roleService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - roleService, - params, - response, - ) + return Objects.hash( + roleService, + params, + response, + ) } - override fun toString() = - "RoleListPageAsync{roleService=$roleService, params=$params, response=$response}" + override fun toString() = "RoleListPageAsync{roleService=$roleService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): RoleListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - RoleListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - RoleListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + RoleListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + RoleListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): RoleListPageAsync? { - return getNextPageParams()?.let { roleService.list(it) } + return getNextPageParams()?.let { + roleService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(roleService: RoleServiceAsync, params: RoleListParams, response: Response) = - RoleListPageAsync( - roleService, - params, - response, - ) + fun of(roleService: RoleServiceAsync, params: RoleListParams, response: Response) = RoleListPageAsync( + roleService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -102,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "RoleListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "RoleListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -155,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: RoleListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: RoleListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt index cfc2b22e..54f8e38c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleListParams.kt @@ -2,33 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class RoleListParams constructor( + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val roleName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class RoleListParams -constructor( - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val roleName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun endingBefore(): String? = endingBefore @@ -44,15 +61,27 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.roleName?.let { params.put("role_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.roleName?.let { + params.put("role_name", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -62,36 +91,35 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleListParams && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.roleName == other.roleName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is RoleListParams && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.roleName == other.roleName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - endingBefore, - ids, - limit, - orgName, - roleName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + endingBefore, + ids, + limit, + orgName, + roleName, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "RoleListParams{endingBefore=$endingBefore, ids=$ids, limit=$limit, orgName=$orgName, roleName=$roleName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -126,47 +154,63 @@ 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** Name of the role to search for */ - fun roleName(roleName: String) = apply { this.roleName = roleName } + fun roleName(roleName: String) = apply { + this.roleName = roleName + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -206,82 +250,77 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): RoleListParams = - RoleListParams( - endingBefore, - ids, - limit, - orgName, - roleName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): RoleListParams = RoleListParams( + endingBefore, + ids, + limit, + orgName, + roleName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -298,38 +337,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt index b05f87e6..d597a61f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleReplaceParams.kt @@ -2,31 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class RoleReplaceParams constructor( + private val name: String, + private val description: String?, + private val memberPermissions: List?, + private val memberRoles: List?, + private val orgName: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class RoleReplaceParams -constructor( - private val name: String, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -40,14 +59,14 @@ constructor( fun orgName(): String? = orgName internal fun getBody(): RoleReplaceBody { - return RoleReplaceBody( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalBodyProperties, - ) + return RoleReplaceBody( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -56,23 +75,25 @@ constructor( @JsonDeserialize(builder = RoleReplaceBody.Builder::class) @NoAutoDetect - class RoleReplaceBody - internal constructor( - private val name: String?, - private val description: String?, - private val memberPermissions: List?, - private val memberRoles: List?, - private val orgName: String?, - private val additionalProperties: Map, + class RoleReplaceBody internal constructor( + private val name: String?, + private val description: String?, + private val memberPermissions: List?, + private val memberRoles: List?, + private val orgName: String?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the role */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Textual description of the role */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -81,17 +102,19 @@ 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") fun memberRoles(): List? = memberRoles + @JsonProperty("member_roles") + fun memberRoles(): List? = 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") fun orgName(): String? = orgName + @JsonProperty("org_name") + fun orgName(): String? = orgName @JsonAnyGetter @ExcludeMissing @@ -100,36 +123,34 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleReplaceBody && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RoleReplaceBody && + this.name == other.name && + this.description == other.description && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.orgName == other.orgName && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" + override fun toString() = "RoleReplaceBody{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalProperties=$additionalProperties}" companion object { @@ -155,11 +176,16 @@ constructor( } /** Name of the role */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Textual description of the role */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ @JsonProperty("member_permissions") @@ -170,19 +196,23 @@ 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") - fun memberRoles(memberRoles: List) = apply { this.memberRoles = memberRoles } + fun memberRoles(memberRoles: List) = apply { + this.memberRoles = 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") - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -198,15 +228,16 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RoleReplaceBody = - RoleReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - description, - memberPermissions?.toUnmodifiable(), - memberRoles?.toUnmodifiable(), - orgName, - additionalProperties.toUnmodifiable(), - ) + fun build(): RoleReplaceBody = RoleReplaceBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + description, + memberPermissions?.toUnmodifiable(), + memberRoles?.toUnmodifiable(), + orgName, + additionalProperties.toUnmodifiable(), + ) } } @@ -217,36 +248,35 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleReplaceParams && - this.name == other.name && - this.description == other.description && - this.memberPermissions == other.memberPermissions && - this.memberRoles == other.memberRoles && - this.orgName == other.orgName && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is RoleReplaceParams && + this.name == other.name && + this.description == other.description && + this.memberPermissions == other.memberPermissions && + this.memberRoles == other.memberRoles && + this.orgName == other.orgName && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - description, - memberPermissions, - memberRoles, - orgName, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + description, + memberPermissions, + memberRoles, + orgName, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "RoleReplaceParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "RoleReplaceParams{name=$name, description=$description, memberPermissions=$memberPermissions, memberRoles=$memberRoles, orgName=$orgName, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -279,10 +309,14 @@ constructor( } /** Name of the role */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Textual description of the role */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** (permission, restrict_object_type) tuples which belong to this role */ fun memberPermissions(memberPermissions: List) = apply { @@ -298,8 +332,8 @@ 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(memberRoles: List) = apply { this.memberRoles.clear() @@ -309,17 +343,21 @@ 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 addMemberRole(memberRole: String) = apply { this.memberRoles.add(memberRole) } + fun addMemberRole(memberRole: String) = apply { + this.memberRoles.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) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -359,7 +397,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -370,41 +410,38 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): RoleReplaceParams = - RoleReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - description, - if (memberPermissions.size == 0) null else memberPermissions.toUnmodifiable(), - if (memberRoles.size == 0) null else memberRoles.toUnmodifiable(), - orgName, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): RoleReplaceParams = RoleReplaceParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + description, + if(memberPermissions.size == 0) null else memberPermissions.toUnmodifiable(), + if(memberRoles.size == 0) null else memberRoles.toUnmodifiable(), + orgName, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = MemberPermission.Builder::class) @NoAutoDetect - class MemberPermission - private constructor( - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val additionalProperties: Map, - ) { + class MemberPermission private constructor(private val permission: Permission?, private val restrictObjectType: RestrictObjectType?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** * 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") fun permission(): Permission? = permission + @JsonProperty("permission") + fun permission(): Permission? = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -417,30 +454,28 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is MemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "MemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" companion object { @@ -462,11 +497,13 @@ constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Permission) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -488,28 +525,25 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): MemberPermission = - MemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): MemberPermission = MemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) } - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && this.value == other.value + return other is Permission && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -560,49 +594,45 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && this.value == other.value + return other is RestrictObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -665,38 +695,35 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt index abf16d9d..c84c6f83 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class RoleRetrieveParams -constructor( - private val roleId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class RoleRetrieveParams constructor(private val roleId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun roleId(): String = roleId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleRetrieveParams && - this.roleId == other.roleId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is RoleRetrieveParams && + this.roleId == other.roleId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - roleId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + roleId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "RoleRetrieveParams{roleId=$roleId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "RoleRetrieveParams{roleId=$roleId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** Role id */ - fun roleId(roleId: String) = apply { this.roleId = roleId } + fun roleId(roleId: String) = apply { + this.roleId = roleId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): RoleRetrieveParams = - RoleRetrieveParams( - checkNotNull(roleId) { "`roleId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): RoleRetrieveParams = RoleRetrieveParams( + checkNotNull(roleId) { + "`roleId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt index bf54b82b..7ee2e3c7 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/RoleUpdateParams.kt @@ -2,33 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class RoleUpdateParams constructor( + private val roleId: String, + private val addMemberPermissions: List?, + private val addMemberRoles: List?, + private val description: String?, + private val name: String?, + private val removeMemberPermissions: List?, + private val removeMemberRoles: List?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class RoleUpdateParams -constructor( - private val roleId: String, - private val addMemberPermissions: List?, - private val addMemberRoles: List?, - private val description: String?, - private val name: String?, - private val removeMemberPermissions: List?, - private val removeMemberRoles: List?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun roleId(): String = roleId @@ -46,15 +65,15 @@ constructor( fun removeMemberRoles(): List? = removeMemberRoles internal fun getBody(): RoleUpdateBody { - return RoleUpdateBody( - addMemberPermissions, - addMemberRoles, - description, - name, - removeMemberPermissions, - removeMemberRoles, - additionalBodyProperties, - ) + return RoleUpdateBody( + addMemberPermissions, + addMemberRoles, + description, + name, + removeMemberPermissions, + removeMemberRoles, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -62,23 +81,23 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> roleId - else -> "" - } + return when (index) { + 0 -> roleId + else -> "" + } } @JsonDeserialize(builder = RoleUpdateBody.Builder::class) @NoAutoDetect - class RoleUpdateBody - internal constructor( - private val addMemberPermissions: List?, - private val addMemberRoles: List?, - private val description: String?, - private val name: String?, - private val removeMemberPermissions: List?, - private val removeMemberRoles: List?, - private val additionalProperties: Map, + class RoleUpdateBody internal constructor( + private val addMemberPermissions: List?, + private val addMemberRoles: List?, + private val description: String?, + private val name: String?, + private val removeMemberPermissions: List?, + private val removeMemberRoles: List?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 @@ -88,13 +107,16 @@ constructor( fun addMemberPermissions(): List? = addMemberPermissions /** A list of role IDs to add to the role's inheriting-from set */ - @JsonProperty("add_member_roles") fun addMemberRoles(): List? = addMemberRoles + @JsonProperty("add_member_roles") + fun addMemberRoles(): List? = addMemberRoles /** Textual description of the role */ - @JsonProperty("description") fun description(): String? = description + @JsonProperty("description") + fun description(): String? = description /** Name of the role */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** A list of permissions to remove from the role */ @JsonProperty("remove_member_permissions") @@ -111,38 +133,36 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleUpdateBody && - this.addMemberPermissions == other.addMemberPermissions && - this.addMemberRoles == other.addMemberRoles && - this.description == other.description && - this.name == other.name && - this.removeMemberPermissions == other.removeMemberPermissions && - this.removeMemberRoles == other.removeMemberRoles && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RoleUpdateBody && + this.addMemberPermissions == other.addMemberPermissions && + this.addMemberRoles == other.addMemberRoles && + this.description == other.description && + this.name == other.name && + this.removeMemberPermissions == other.removeMemberPermissions && + this.removeMemberRoles == other.removeMemberRoles && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - addMemberPermissions, - addMemberRoles, - description, - name, - removeMemberPermissions, - removeMemberRoles, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + addMemberPermissions, + addMemberRoles, + description, + name, + removeMemberPermissions, + removeMemberRoles, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" + override fun toString() = "RoleUpdateBody{addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalProperties=$additionalProperties}" companion object { @@ -183,17 +203,21 @@ constructor( /** Textual description of the role */ @JsonProperty("description") - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Name of the role */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** A list of permissions to remove from the role */ @JsonProperty("remove_member_permissions") - fun removeMemberPermissions(removeMemberPermissions: List) = - apply { - this.removeMemberPermissions = removeMemberPermissions - } + fun removeMemberPermissions(removeMemberPermissions: List) = apply { + this.removeMemberPermissions = removeMemberPermissions + } /** A list of role IDs to remove from the role's inheriting-from set */ @JsonProperty("remove_member_roles") @@ -215,16 +239,15 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RoleUpdateBody = - RoleUpdateBody( - addMemberPermissions?.toUnmodifiable(), - addMemberRoles?.toUnmodifiable(), - description, - name, - removeMemberPermissions?.toUnmodifiable(), - removeMemberRoles?.toUnmodifiable(), - additionalProperties.toUnmodifiable(), - ) + fun build(): RoleUpdateBody = RoleUpdateBody( + addMemberPermissions?.toUnmodifiable(), + addMemberRoles?.toUnmodifiable(), + description, + name, + removeMemberPermissions?.toUnmodifiable(), + removeMemberRoles?.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) } } @@ -235,40 +258,39 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoleUpdateParams && - this.roleId == other.roleId && - this.addMemberPermissions == other.addMemberPermissions && - this.addMemberRoles == other.addMemberRoles && - this.description == other.description && - this.name == other.name && - this.removeMemberPermissions == other.removeMemberPermissions && - this.removeMemberRoles == other.removeMemberRoles && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is RoleUpdateParams && + this.roleId == other.roleId && + this.addMemberPermissions == other.addMemberPermissions && + this.addMemberRoles == other.addMemberRoles && + this.description == other.description && + this.name == other.name && + this.removeMemberPermissions == other.removeMemberPermissions && + this.removeMemberRoles == other.removeMemberRoles && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - roleId, - addMemberPermissions, - addMemberRoles, - description, - name, - removeMemberPermissions, - removeMemberRoles, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + roleId, + addMemberPermissions, + addMemberRoles, + description, + name, + removeMemberPermissions, + removeMemberRoles, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "RoleUpdateParams{roleId=$roleId, addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "RoleUpdateParams{roleId=$roleId, addMemberPermissions=$addMemberPermissions, addMemberRoles=$addMemberRoles, description=$description, name=$name, removeMemberPermissions=$removeMemberPermissions, removeMemberRoles=$removeMemberRoles, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -305,7 +327,9 @@ constructor( } /** 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 { @@ -330,10 +354,14 @@ constructor( } /** Textual description of the role */ - fun description(description: String) = apply { this.description = description } + fun description(description: String) = apply { + this.description = description + } /** Name of the role */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** A list of permissions to remove from the role */ fun removeMemberPermissions(removeMemberPermissions: List) = apply { @@ -395,7 +423,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -406,44 +436,40 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): RoleUpdateParams = - RoleUpdateParams( - checkNotNull(roleId) { "`roleId` is required but was not set" }, - if (addMemberPermissions.size == 0) null else addMemberPermissions.toUnmodifiable(), - if (addMemberRoles.size == 0) null else addMemberRoles.toUnmodifiable(), - description, - name, - if (removeMemberPermissions.size == 0) null - else removeMemberPermissions.toUnmodifiable(), - if (removeMemberRoles.size == 0) null else removeMemberRoles.toUnmodifiable(), - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): RoleUpdateParams = RoleUpdateParams( + checkNotNull(roleId) { + "`roleId` is required but was not set" + }, + if(addMemberPermissions.size == 0) null else addMemberPermissions.toUnmodifiable(), + if(addMemberRoles.size == 0) null else addMemberRoles.toUnmodifiable(), + description, + name, + if(removeMemberPermissions.size == 0) null else removeMemberPermissions.toUnmodifiable(), + if(removeMemberRoles.size == 0) null else removeMemberRoles.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = AddMemberPermission.Builder::class) @NoAutoDetect - class AddMemberPermission - private constructor( - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val additionalProperties: Map, - ) { + class AddMemberPermission private constructor(private val permission: Permission?, private val restrictObjectType: RestrictObjectType?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** * 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") fun permission(): Permission? = permission + @JsonProperty("permission") + fun permission(): Permission? = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -456,30 +482,28 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AddMemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is AddMemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "AddMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" companion object { @@ -501,11 +525,13 @@ constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Permission) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -527,28 +553,25 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): AddMemberPermission = - AddMemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): AddMemberPermission = AddMemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) } - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && this.value == other.value + return other is Permission && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -599,49 +622,45 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && this.value == other.value + return other is RestrictObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -704,38 +723,35 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } @@ -743,21 +759,18 @@ constructor( @JsonDeserialize(builder = RemoveMemberPermission.Builder::class) @NoAutoDetect - class RemoveMemberPermission - private constructor( - private val permission: Permission?, - private val restrictObjectType: RestrictObjectType?, - private val additionalProperties: Map, - ) { + class RemoveMemberPermission private constructor(private val permission: Permission?, private val restrictObjectType: RestrictObjectType?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** * 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") fun permission(): Permission? = permission + @JsonProperty("permission") + fun permission(): Permission? = permission /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -770,30 +783,28 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RemoveMemberPermission && - this.permission == other.permission && - this.restrictObjectType == other.restrictObjectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is RemoveMemberPermission && + this.permission == other.permission && + this.restrictObjectType == other.restrictObjectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - permission, - restrictObjectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + permission, + restrictObjectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" + override fun toString() = "RemoveMemberPermission{permission=$permission, restrictObjectType=$restrictObjectType, additionalProperties=$additionalProperties}" companion object { @@ -815,11 +826,13 @@ constructor( /** * Each permission permits a certain type of operation on an object in the system * - * Permissions can be assigned to to objects on an individual basis, or grouped into - * roles + * Permissions can be assigned to to objects on an individual basis, or grouped + * into roles */ @JsonProperty("permission") - fun permission(permission: Permission) = apply { this.permission = permission } + fun permission(permission: Permission) = apply { + this.permission = permission + } /** The object type that the ACL applies to */ @JsonProperty("restrict_object_type") @@ -841,28 +854,25 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): RemoveMemberPermission = - RemoveMemberPermission( - permission, - restrictObjectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): RemoveMemberPermission = RemoveMemberPermission( + permission, + restrictObjectType, + additionalProperties.toUnmodifiable(), + ) } - class Permission - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class Permission @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Permission && this.value == other.value + return other is Permission && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -913,49 +923,45 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - CREATE -> Value.CREATE - READ -> Value.READ - UPDATE -> Value.UPDATE - DELETE -> Value.DELETE - CREATE_ACLS -> Value.CREATE_ACLS - READ_ACLS -> Value.READ_ACLS - UPDATE_ACLS -> Value.UPDATE_ACLS - DELETE_ACLS -> Value.DELETE_ACLS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - CREATE -> Known.CREATE - READ -> Known.READ - UPDATE -> Known.UPDATE - DELETE -> Known.DELETE - CREATE_ACLS -> Known.CREATE_ACLS - READ_ACLS -> Known.READ_ACLS - UPDATE_ACLS -> Known.UPDATE_ACLS - DELETE_ACLS -> Known.DELETE_ACLS - else -> throw BraintrustInvalidDataException("Unknown Permission: $value") - } + fun value(): Value = when (this) { + CREATE -> Value.CREATE + READ -> Value.READ + UPDATE -> Value.UPDATE + DELETE -> Value.DELETE + CREATE_ACLS -> Value.CREATE_ACLS + READ_ACLS -> Value.READ_ACLS + UPDATE_ACLS -> Value.UPDATE_ACLS + DELETE_ACLS -> Value.DELETE_ACLS + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + CREATE -> Known.CREATE + READ -> Known.READ + UPDATE -> Known.UPDATE + DELETE -> Known.DELETE + CREATE_ACLS -> Known.CREATE_ACLS + READ_ACLS -> Known.READ_ACLS + UPDATE_ACLS -> Known.UPDATE_ACLS + DELETE_ACLS -> Known.DELETE_ACLS + else -> throw BraintrustInvalidDataException("Unknown Permission: $value") + } fun asString(): String = _value().asStringOrThrow() } - class RestrictObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class RestrictObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is RestrictObjectType && this.value == other.value + return other is RestrictObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -1018,38 +1024,35 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> - throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown RestrictObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt index 63528161..65faf3b5 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ScoreSummary.kt @@ -2,29 +2,48 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** Summary of a score's performance */ @JsonDeserialize(builder = ScoreSummary.Builder::class) @NoAutoDetect -class ScoreSummary -private constructor( - private val name: JsonField, - private val score: JsonField, - private val diff: JsonField, - private val improvements: JsonField, - private val regressions: JsonField, - private val additionalProperties: Map, +class ScoreSummary private constructor( + private val name: JsonField, + private val score: JsonField, + private val diff: JsonField, + private val improvements: JsonField, + private val regressions: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -47,19 +66,29 @@ private constructor( fun regressions(): Long = regressions.getRequired("regressions") /** Name of the score */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Average score across all examples */ - @JsonProperty("score") @ExcludeMissing fun _score() = score + @JsonProperty("score") + @ExcludeMissing + fun _score() = score /** Difference in score between the current and comparison experiment */ - @JsonProperty("diff") @ExcludeMissing fun _diff() = diff + @JsonProperty("diff") + @ExcludeMissing + fun _diff() = diff /** Number of improvements in the score */ - @JsonProperty("improvements") @ExcludeMissing fun _improvements() = improvements + @JsonProperty("improvements") + @ExcludeMissing + fun _improvements() = improvements /** Number of regressions in the score */ - @JsonProperty("regressions") @ExcludeMissing fun _regressions() = regressions + @JsonProperty("regressions") + @ExcludeMissing + fun _regressions() = regressions @JsonAnyGetter @ExcludeMissing @@ -67,48 +96,46 @@ private constructor( fun validate(): ScoreSummary = apply { if (!validated) { - name() - score() - diff() - improvements() - regressions() - validated = true + name() + score() + diff() + improvements() + regressions() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ScoreSummary && - this.name == other.name && - this.score == other.score && - this.diff == other.diff && - this.improvements == other.improvements && - this.regressions == other.regressions && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ScoreSummary && + this.name == other.name && + this.score == other.score && + this.diff == other.diff && + this.improvements == other.improvements && + this.regressions == other.regressions && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - score, - diff, - improvements, - regressions, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + score, + diff, + improvements, + regressions, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ScoreSummary{name=$name, score=$score, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" + override fun toString() = "ScoreSummary{name=$name, score=$score, diff=$diff, improvements=$improvements, regressions=$regressions, additionalProperties=$additionalProperties}" companion object { @@ -139,7 +166,9 @@ private constructor( /** Name of the score */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } /** Average score across all examples */ fun score(score: Double) = score(JsonField.of(score)) @@ -147,7 +176,9 @@ private constructor( /** Average score across all examples */ @JsonProperty("score") @ExcludeMissing - 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)) @@ -155,7 +186,9 @@ private constructor( /** Difference in score between the current and comparison experiment */ @JsonProperty("diff") @ExcludeMissing - fun diff(diff: JsonField) = apply { this.diff = diff } + fun diff(diff: JsonField) = apply { + this.diff = diff + } /** Number of improvements in the score */ fun improvements(improvements: Long) = improvements(JsonField.of(improvements)) @@ -163,7 +196,9 @@ private constructor( /** Number of improvements in the score */ @JsonProperty("improvements") @ExcludeMissing - fun improvements(improvements: JsonField) = apply { this.improvements = improvements } + fun improvements(improvements: JsonField) = apply { + this.improvements = improvements + } /** Number of regressions in the score */ fun regressions(regressions: Long) = regressions(JsonField.of(regressions)) @@ -171,7 +206,9 @@ private constructor( /** Number of regressions in the score */ @JsonProperty("regressions") @ExcludeMissing - fun regressions(regressions: JsonField) = apply { this.regressions = regressions } + fun regressions(regressions: JsonField) = apply { + this.regressions = regressions + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -187,14 +224,13 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ScoreSummary = - ScoreSummary( - name, - score, - diff, - improvements, - regressions, - additionalProperties.toUnmodifiable(), - ) + fun build(): ScoreSummary = ScoreSummary( + name, + score, + diff, + improvements, + regressions, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt index a97c8dc3..5b846e7d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponse.kt @@ -2,29 +2,48 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** Summary of a dataset */ @JsonDeserialize(builder = SummarizeDatasetResponse.Builder::class) @NoAutoDetect -class SummarizeDatasetResponse -private constructor( - private val projectName: JsonField, - private val datasetName: JsonField, - private val projectUrl: JsonField, - private val datasetUrl: JsonField, - private val dataSummary: JsonField, - private val additionalProperties: Map, +class SummarizeDatasetResponse private constructor( + private val projectName: JsonField, + private val datasetName: JsonField, + private val projectUrl: JsonField, + private val datasetUrl: JsonField, + private val dataSummary: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -47,19 +66,29 @@ private constructor( fun dataSummary(): DataSummary? = dataSummary.getNullable("data_summary") /** Name of the project that the dataset belongs to */ - @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName + @JsonProperty("project_name") + @ExcludeMissing + fun _projectName() = projectName /** Name of the dataset */ - @JsonProperty("dataset_name") @ExcludeMissing fun _datasetName() = datasetName + @JsonProperty("dataset_name") + @ExcludeMissing + fun _datasetName() = datasetName /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") @ExcludeMissing fun _projectUrl() = projectUrl + @JsonProperty("project_url") + @ExcludeMissing + fun _projectUrl() = projectUrl /** URL to the dataset's page in the Braintrust app */ - @JsonProperty("dataset_url") @ExcludeMissing fun _datasetUrl() = datasetUrl + @JsonProperty("dataset_url") + @ExcludeMissing + fun _datasetUrl() = datasetUrl /** Summary of a dataset's data */ - @JsonProperty("data_summary") @ExcludeMissing fun _dataSummary() = dataSummary + @JsonProperty("data_summary") + @ExcludeMissing + fun _dataSummary() = dataSummary @JsonAnyGetter @ExcludeMissing @@ -67,48 +96,46 @@ private constructor( fun validate(): SummarizeDatasetResponse = apply { if (!validated) { - projectName() - datasetName() - projectUrl() - datasetUrl() - dataSummary()?.validate() - validated = true + projectName() + datasetName() + projectUrl() + datasetUrl() + dataSummary()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SummarizeDatasetResponse && - this.projectName == other.projectName && - this.datasetName == other.datasetName && - this.projectUrl == other.projectUrl && - this.datasetUrl == other.datasetUrl && - this.dataSummary == other.dataSummary && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SummarizeDatasetResponse && + this.projectName == other.projectName && + this.datasetName == other.datasetName && + this.projectUrl == other.projectUrl && + this.datasetUrl == other.datasetUrl && + this.dataSummary == other.dataSummary && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectName, - datasetName, - projectUrl, - datasetUrl, - dataSummary, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + projectName, + datasetName, + projectUrl, + datasetUrl, + dataSummary, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "SummarizeDatasetResponse{projectName=$projectName, datasetName=$datasetName, projectUrl=$projectUrl, datasetUrl=$datasetUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" + override fun toString() = "SummarizeDatasetResponse{projectName=$projectName, datasetName=$datasetName, projectUrl=$projectUrl, datasetUrl=$datasetUrl, dataSummary=$dataSummary, additionalProperties=$additionalProperties}" companion object { @@ -139,7 +166,9 @@ private constructor( /** Name of the project that the dataset belongs to */ @JsonProperty("project_name") @ExcludeMissing - fun projectName(projectName: JsonField) = apply { this.projectName = projectName } + fun projectName(projectName: JsonField) = apply { + this.projectName = projectName + } /** Name of the dataset */ fun datasetName(datasetName: String) = datasetName(JsonField.of(datasetName)) @@ -147,7 +176,9 @@ private constructor( /** Name of the dataset */ @JsonProperty("dataset_name") @ExcludeMissing - fun datasetName(datasetName: JsonField) = apply { this.datasetName = datasetName } + fun datasetName(datasetName: JsonField) = apply { + this.datasetName = datasetName + } /** URL to the project's page in the Braintrust app */ fun projectUrl(projectUrl: String) = projectUrl(JsonField.of(projectUrl)) @@ -155,7 +186,9 @@ private constructor( /** URL to the project's page in the Braintrust app */ @JsonProperty("project_url") @ExcludeMissing - fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } + fun projectUrl(projectUrl: JsonField) = apply { + this.projectUrl = projectUrl + } /** URL to the dataset's page in the Braintrust app */ fun datasetUrl(datasetUrl: String) = datasetUrl(JsonField.of(datasetUrl)) @@ -163,7 +196,9 @@ private constructor( /** URL to the dataset's page in the Braintrust app */ @JsonProperty("dataset_url") @ExcludeMissing - fun datasetUrl(datasetUrl: JsonField) = apply { this.datasetUrl = datasetUrl } + fun datasetUrl(datasetUrl: JsonField) = apply { + this.datasetUrl = datasetUrl + } /** Summary of a dataset's data */ fun dataSummary(dataSummary: DataSummary) = dataSummary(JsonField.of(dataSummary)) @@ -189,14 +224,13 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): SummarizeDatasetResponse = - SummarizeDatasetResponse( - projectName, - datasetName, - projectUrl, - datasetUrl, - dataSummary, - additionalProperties.toUnmodifiable(), - ) + fun build(): SummarizeDatasetResponse = SummarizeDatasetResponse( + projectName, + datasetName, + projectUrl, + datasetUrl, + dataSummary, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt index 0707694b..762d7230 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponse.kt @@ -2,31 +2,50 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** Summary of an experiment */ @JsonDeserialize(builder = SummarizeExperimentResponse.Builder::class) @NoAutoDetect -class SummarizeExperimentResponse -private constructor( - private val projectName: JsonField, - private val experimentName: JsonField, - private val projectUrl: JsonField, - private val experimentUrl: JsonField, - private val comparisonExperimentName: JsonField, - private val scores: JsonField, - private val metrics: JsonField, - private val additionalProperties: Map, +class SummarizeExperimentResponse private constructor( + private val projectName: JsonField, + private val experimentName: JsonField, + private val projectUrl: JsonField, + private val experimentUrl: JsonField, + private val comparisonExperimentName: JsonField, + private val scores: JsonField, + private val metrics: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -46,8 +65,7 @@ private constructor( fun experimentUrl(): String = experimentUrl.getRequired("experiment_url") /** The experiment which scores are baselined against */ - fun comparisonExperimentName(): String? = - comparisonExperimentName.getNullable("comparison_experiment_name") + fun comparisonExperimentName(): String? = comparisonExperimentName.getNullable("comparison_experiment_name") /** Summary of the experiment's scores */ fun scores(): Scores? = scores.getNullable("scores") @@ -56,16 +74,24 @@ private constructor( fun metrics(): Metrics? = metrics.getNullable("metrics") /** Name of the project that the experiment belongs to */ - @JsonProperty("project_name") @ExcludeMissing fun _projectName() = projectName + @JsonProperty("project_name") + @ExcludeMissing + fun _projectName() = projectName /** Name of the experiment */ - @JsonProperty("experiment_name") @ExcludeMissing fun _experimentName() = experimentName + @JsonProperty("experiment_name") + @ExcludeMissing + fun _experimentName() = experimentName /** URL to the project's page in the Braintrust app */ - @JsonProperty("project_url") @ExcludeMissing fun _projectUrl() = projectUrl + @JsonProperty("project_url") + @ExcludeMissing + fun _projectUrl() = projectUrl /** URL to the experiment's page in the Braintrust app */ - @JsonProperty("experiment_url") @ExcludeMissing fun _experimentUrl() = experimentUrl + @JsonProperty("experiment_url") + @ExcludeMissing + fun _experimentUrl() = experimentUrl /** The experiment which scores are baselined against */ @JsonProperty("comparison_experiment_name") @@ -73,10 +99,14 @@ private constructor( fun _comparisonExperimentName() = comparisonExperimentName /** Summary of the experiment's scores */ - @JsonProperty("scores") @ExcludeMissing fun _scores() = scores + @JsonProperty("scores") + @ExcludeMissing + fun _scores() = scores /** Summary of the experiment's metrics */ - @JsonProperty("metrics") @ExcludeMissing fun _metrics() = metrics + @JsonProperty("metrics") + @ExcludeMissing + fun _metrics() = metrics @JsonAnyGetter @ExcludeMissing @@ -84,54 +114,52 @@ private constructor( fun validate(): SummarizeExperimentResponse = apply { if (!validated) { - projectName() - experimentName() - projectUrl() - experimentUrl() - comparisonExperimentName() - scores()?.validate() - metrics()?.validate() - validated = true + projectName() + experimentName() + projectUrl() + experimentUrl() + comparisonExperimentName() + scores()?.validate() + metrics()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SummarizeExperimentResponse && - this.projectName == other.projectName && - this.experimentName == other.experimentName && - this.projectUrl == other.projectUrl && - this.experimentUrl == other.experimentUrl && - this.comparisonExperimentName == other.comparisonExperimentName && - this.scores == other.scores && - this.metrics == other.metrics && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is SummarizeExperimentResponse && + this.projectName == other.projectName && + this.experimentName == other.experimentName && + this.projectUrl == other.projectUrl && + this.experimentUrl == other.experimentUrl && + this.comparisonExperimentName == other.comparisonExperimentName && + this.scores == other.scores && + this.metrics == other.metrics && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - projectName, - experimentName, - projectUrl, - experimentUrl, - comparisonExperimentName, - scores, - metrics, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + projectName, + experimentName, + projectUrl, + experimentUrl, + comparisonExperimentName, + scores, + metrics, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "SummarizeExperimentResponse{projectName=$projectName, experimentName=$experimentName, projectUrl=$projectUrl, experimentUrl=$experimentUrl, comparisonExperimentName=$comparisonExperimentName, scores=$scores, metrics=$metrics, additionalProperties=$additionalProperties}" + override fun toString() = "SummarizeExperimentResponse{projectName=$projectName, experimentName=$experimentName, projectUrl=$projectUrl, experimentUrl=$experimentUrl, comparisonExperimentName=$comparisonExperimentName, scores=$scores, metrics=$metrics, additionalProperties=$additionalProperties}" companion object { @@ -166,7 +194,9 @@ private constructor( /** Name of the project that the experiment belongs to */ @JsonProperty("project_name") @ExcludeMissing - fun projectName(projectName: JsonField) = apply { this.projectName = projectName } + fun projectName(projectName: JsonField) = apply { + this.projectName = projectName + } /** Name of the experiment */ fun experimentName(experimentName: String) = experimentName(JsonField.of(experimentName)) @@ -184,7 +214,9 @@ private constructor( /** URL to the project's page in the Braintrust app */ @JsonProperty("project_url") @ExcludeMissing - fun projectUrl(projectUrl: JsonField) = apply { this.projectUrl = projectUrl } + fun projectUrl(projectUrl: JsonField) = apply { + this.projectUrl = projectUrl + } /** URL to the experiment's page in the Braintrust app */ fun experimentUrl(experimentUrl: String) = experimentUrl(JsonField.of(experimentUrl)) @@ -197,8 +229,7 @@ private constructor( } /** The experiment which scores are baselined against */ - fun comparisonExperimentName(comparisonExperimentName: String) = - comparisonExperimentName(JsonField.of(comparisonExperimentName)) + fun comparisonExperimentName(comparisonExperimentName: String) = comparisonExperimentName(JsonField.of(comparisonExperimentName)) /** The experiment which scores are baselined against */ @JsonProperty("comparison_experiment_name") @@ -213,7 +244,9 @@ private constructor( /** Summary of the experiment's scores */ @JsonProperty("scores") @ExcludeMissing - fun scores(scores: JsonField) = apply { this.scores = scores } + fun scores(scores: JsonField) = apply { + this.scores = scores + } /** Summary of the experiment's metrics */ fun metrics(metrics: Metrics) = metrics(JsonField.of(metrics)) @@ -221,7 +254,9 @@ private constructor( /** Summary of the experiment's metrics */ @JsonProperty("metrics") @ExcludeMissing - fun metrics(metrics: JsonField) = apply { this.metrics = metrics } + fun metrics(metrics: JsonField) = apply { + this.metrics = metrics + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -237,26 +272,22 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): SummarizeExperimentResponse = - SummarizeExperimentResponse( - projectName, - experimentName, - projectUrl, - experimentUrl, - comparisonExperimentName, - scores, - metrics, - additionalProperties.toUnmodifiable(), - ) + fun build(): SummarizeExperimentResponse = SummarizeExperimentResponse( + projectName, + experimentName, + projectUrl, + experimentUrl, + comparisonExperimentName, + scores, + metrics, + additionalProperties.toUnmodifiable(), + ) } /** Summary of the experiment's metrics */ @JsonDeserialize(builder = Metrics.Builder::class) @NoAutoDetect - class Metrics - private constructor( - private val additionalProperties: Map, - ) { + class Metrics private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -268,25 +299,26 @@ private constructor( fun validate(): Metrics = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Metrics && this.additionalProperties == other.additionalProperties + return other is Metrics && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Metrics{additionalProperties=$additionalProperties}" @@ -325,10 +357,7 @@ private constructor( /** Summary of the experiment's scores */ @JsonDeserialize(builder = Scores.Builder::class) @NoAutoDetect - class Scores - private constructor( - private val additionalProperties: Map, - ) { + class Scores private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -340,25 +369,26 @@ private constructor( fun validate(): Scores = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Scores && this.additionalProperties == other.additionalProperties + return other is Scores && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "Scores{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt index 152c611c..937f3c44 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParams.kt @@ -2,16 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class TopLevelHelloWorldParams -constructor( - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class TopLevelHelloWorldParams constructor(private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { internal fun getQueryParams(): Map> = additionalQueryParams @@ -22,21 +47,20 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is TopLevelHelloWorldParams && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + return other is TopLevelHelloWorldParams && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash(additionalQueryParams, additionalHeaders) + return Objects.hash(additionalQueryParams, additionalHeaders) } - override fun toString() = - "TopLevelHelloWorldParams{additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "TopLevelHelloWorldParams{additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -94,12 +118,10 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): TopLevelHelloWorldParams = - TopLevelHelloWorldParams( - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable() - ) + fun build(): TopLevelHelloWorldParams = TopLevelHelloWorldParams(additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable()) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/User.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/User.kt index 914d2158..9003e1cc 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/User.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/User.kt @@ -2,30 +2,48 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = User.Builder::class) @NoAutoDetect -class User -private constructor( - private val id: JsonField, - private val givenName: JsonField, - private val familyName: JsonField, - private val email: JsonField, - private val avatarUrl: JsonField, - private val created: JsonField, - private val additionalProperties: Map, +class User private constructor( + private val id: JsonField, + private val givenName: JsonField, + private val familyName: JsonField, + private val email: JsonField, + private val avatarUrl: JsonField, + private val created: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -51,22 +69,34 @@ private constructor( fun created(): OffsetDateTime? = created.getNullable("created") /** Unique identifier for the user */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** Given name of the user */ - @JsonProperty("given_name") @ExcludeMissing fun _givenName() = givenName + @JsonProperty("given_name") + @ExcludeMissing + fun _givenName() = givenName /** Family name of the user */ - @JsonProperty("family_name") @ExcludeMissing fun _familyName() = familyName + @JsonProperty("family_name") + @ExcludeMissing + fun _familyName() = familyName /** The user's email */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") + @ExcludeMissing + fun _email() = email /** URL of the user's Avatar image */ - @JsonProperty("avatar_url") @ExcludeMissing fun _avatarUrl() = avatarUrl + @JsonProperty("avatar_url") + @ExcludeMissing + fun _avatarUrl() = avatarUrl /** Date of user creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created @JsonAnyGetter @ExcludeMissing @@ -74,51 +104,49 @@ private constructor( fun validate(): User = apply { if (!validated) { - id() - givenName() - familyName() - email() - avatarUrl() - created() - validated = true + id() + givenName() + familyName() + email() + avatarUrl() + created() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is User && - this.id == other.id && - this.givenName == other.givenName && - this.familyName == other.familyName && - this.email == other.email && - this.avatarUrl == other.avatarUrl && - this.created == other.created && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is User && + this.id == other.id && + this.givenName == other.givenName && + this.familyName == other.familyName && + this.email == other.email && + this.avatarUrl == other.avatarUrl && + this.created == other.created && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - givenName, - familyName, - email, - avatarUrl, - created, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + givenName, + familyName, + email, + avatarUrl, + created, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "User{id=$id, givenName=$givenName, familyName=$familyName, email=$email, avatarUrl=$avatarUrl, created=$created, additionalProperties=$additionalProperties}" + override fun toString() = "User{id=$id, givenName=$givenName, familyName=$familyName, email=$email, avatarUrl=$avatarUrl, created=$created, additionalProperties=$additionalProperties}" companion object { @@ -149,7 +177,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the user */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** Given name of the user */ fun givenName(givenName: String) = givenName(JsonField.of(givenName)) @@ -157,7 +189,9 @@ private constructor( /** Given name of the user */ @JsonProperty("given_name") @ExcludeMissing - fun givenName(givenName: JsonField) = apply { this.givenName = givenName } + fun givenName(givenName: JsonField) = apply { + this.givenName = givenName + } /** Family name of the user */ fun familyName(familyName: String) = familyName(JsonField.of(familyName)) @@ -165,7 +199,9 @@ private constructor( /** Family name of the user */ @JsonProperty("family_name") @ExcludeMissing - fun familyName(familyName: JsonField) = apply { this.familyName = familyName } + fun familyName(familyName: JsonField) = apply { + this.familyName = familyName + } /** The user's email */ fun email(email: String) = email(JsonField.of(email)) @@ -173,7 +209,9 @@ private constructor( /** The user's email */ @JsonProperty("email") @ExcludeMissing - fun email(email: JsonField) = apply { this.email = email } + fun email(email: JsonField) = apply { + this.email = email + } /** URL of the user's Avatar image */ fun avatarUrl(avatarUrl: String) = avatarUrl(JsonField.of(avatarUrl)) @@ -181,7 +219,9 @@ private constructor( /** URL of the user's Avatar image */ @JsonProperty("avatar_url") @ExcludeMissing - 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.of(created)) @@ -189,7 +229,9 @@ private constructor( /** Date of user creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -205,15 +247,14 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): User = - User( - id, - givenName, - familyName, - email, - avatarUrl, - created, - additionalProperties.toUnmodifiable(), - ) + fun build(): User = User( + id, + givenName, + familyName, + email, + avatarUrl, + created, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserEmail.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserEmail.kt deleted file mode 100755 index 945cfeb8..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserEmail.kt +++ /dev/null @@ -1,130 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(using = UserEmail.Deserializer::class) -@JsonSerialize(using = UserEmail.Serializer::class) -class UserEmail -private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun string(): String? = string - - fun strings(): List? = strings - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): UserEmail = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown UserEmail: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserEmail && this.string == other.string && this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "UserEmail{string=$string}" - strings != null -> "UserEmail{strings=$strings}" - _json != null -> "UserEmail{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UserEmail") - } - } - - companion object { - - fun ofString(string: String) = UserEmail(string = string) - - fun ofStrings(strings: List) = UserEmail(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UserEmail: $json") - } - } - - class Deserializer : BaseDeserializer(UserEmail::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UserEmail { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return UserEmail(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return UserEmail(strings = it, _json = json) - } - - return UserEmail(_json = json) - } - } - - class Serializer : BaseSerializer(UserEmail::class) { - - override fun serialize( - value: UserEmail, - 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 UserEmail") - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserFamilyName.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserFamilyName.kt deleted file mode 100755 index 289c35a2..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserFamilyName.kt +++ /dev/null @@ -1,132 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(using = UserFamilyName.Deserializer::class) -@JsonSerialize(using = UserFamilyName.Serializer::class) -class UserFamilyName -private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun string(): String? = string - - fun strings(): List? = strings - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): UserFamilyName = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown UserFamilyName: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserFamilyName && - this.string == other.string && - this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "UserFamilyName{string=$string}" - strings != null -> "UserFamilyName{strings=$strings}" - _json != null -> "UserFamilyName{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UserFamilyName") - } - } - - companion object { - - fun ofString(string: String) = UserFamilyName(string = string) - - fun ofStrings(strings: List) = UserFamilyName(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UserFamilyName: $json") - } - } - - class Deserializer : BaseDeserializer(UserFamilyName::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UserFamilyName { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return UserFamilyName(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return UserFamilyName(strings = it, _json = json) - } - - return UserFamilyName(_json = json) - } - } - - class Serializer : BaseSerializer(UserFamilyName::class) { - - override fun serialize( - value: UserFamilyName, - 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 UserFamilyName") - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserGivenName.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserGivenName.kt deleted file mode 100755 index 4c69413e..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserGivenName.kt +++ /dev/null @@ -1,132 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Objects - -@JsonDeserialize(using = UserGivenName.Deserializer::class) -@JsonSerialize(using = UserGivenName.Serializer::class) -class UserGivenName -private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, -) { - - private var validated: Boolean = false - - fun string(): String? = string - - fun strings(): List? = strings - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): JsonValue? = _json - - fun accept(visitor: Visitor): T { - return when { - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): UserGivenName = apply { - if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown UserGivenName: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserGivenName && - this.string == other.string && - this.strings == other.strings - } - - override fun hashCode(): Int { - return Objects.hash(string, strings) - } - - override fun toString(): String { - return when { - string != null -> "UserGivenName{string=$string}" - strings != null -> "UserGivenName{strings=$strings}" - _json != null -> "UserGivenName{_unknown=$_json}" - else -> throw IllegalStateException("Invalid UserGivenName") - } - } - - companion object { - - fun ofString(string: String) = UserGivenName(string = string) - - fun ofStrings(strings: List) = UserGivenName(strings = strings) - } - - interface Visitor { - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown UserGivenName: $json") - } - } - - class Deserializer : BaseDeserializer(UserGivenName::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): UserGivenName { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return UserGivenName(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return UserGivenName(strings = it, _json = json) - } - - return UserGivenName(_json = json) - } - } - - class Serializer : BaseSerializer(UserGivenName::class) { - - override fun serialize( - value: UserGivenName, - 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 UserGivenName") - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt index 13cc83cf..6e90a889 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListPage.kt @@ -2,97 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.User import com.braintrustdata.api.services.blocking.UserService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class UserListPage -private constructor( - private val userService: UserService, - private val params: UserListParams, - private val response: Response, -) { +class UserListPage private constructor(private val userService: UserService, private val params: UserListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserListPage && - this.userService == other.userService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is UserListPage && + this.userService == other.userService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - userService, - params, - response, - ) + return Objects.hash( + userService, + params, + response, + ) } - override fun toString() = - "UserListPage{userService=$userService, params=$params, response=$response}" + override fun toString() = "UserListPage{userService=$userService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): UserListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - UserListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - UserListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + UserListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + UserListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): UserListPage? { - return getNextPageParams()?.let { userService.list(it) } + return getNextPageParams()?.let { + userService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(userService: UserService, params: UserListParams, response: Response) = - UserListPage( - userService, - params, - response, - ) + fun of(userService: UserService, params: UserListParams, response: Response) = UserListPage( + userService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -100,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "UserListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "UserListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -153,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: UserListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: UserListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt index 84c4d383..c5216ef7 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListPageAsync.kt @@ -2,99 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.UserServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.User +import com.braintrustdata.api.services.async.UserServiceAsync -class UserListPageAsync -private constructor( - private val userService: UserServiceAsync, - private val params: UserListParams, - private val response: Response, -) { +class UserListPageAsync private constructor(private val userService: UserServiceAsync, private val params: UserListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserListPageAsync && - this.userService == other.userService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is UserListPageAsync && + this.userService == other.userService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - userService, - params, - response, - ) + return Objects.hash( + userService, + params, + response, + ) } - override fun toString() = - "UserListPageAsync{userService=$userService, params=$params, response=$response}" + override fun toString() = "UserListPageAsync{userService=$userService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): UserListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - UserListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - UserListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + UserListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + UserListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): UserListPageAsync? { - return getNextPageParams()?.let { userService.list(it) } + return getNextPageParams()?.let { + userService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(userService: UserServiceAsync, params: UserListParams, response: Response) = - UserListPageAsync( - userService, - params, - response, - ) + fun of(userService: UserServiceAsync, params: UserListParams, response: Response) = UserListPageAsync( + userService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -102,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "UserListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "UserListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -155,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: UserListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: UserListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt index 2897e6ed..ad9c7033 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserListParams.kt @@ -2,35 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class UserListParams constructor( + private val email: Email?, + private val endingBefore: String?, + private val familyName: FamilyName?, + private val givenName: GivenName?, + private val ids: Ids?, + private val limit: Long?, + private val orgName: String?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class UserListParams -constructor( - private val email: Email?, - private val endingBefore: String?, - private val familyName: FamilyName?, - private val givenName: GivenName?, - private val ids: Ids?, - private val limit: Long?, - private val orgName: String?, - private val startingAfter: String?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun email(): Email? = email @@ -50,17 +67,33 @@ constructor( fun startingAfter(): String? = startingAfter internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.email?.let { params.put("email", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.familyName?.let { params.put("family_name", listOf(it.toString())) } - this.givenName?.let { params.put("given_name", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.orgName?.let { params.put("org_name", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.email?.let { + params.put("email", listOf(it.toString())) + } + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.familyName?.let { + params.put("family_name", listOf(it.toString())) + } + this.givenName?.let { + params.put("given_name", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.orgName?.let { + params.put("org_name", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -70,40 +103,39 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserListParams && - this.email == other.email && - this.endingBefore == other.endingBefore && - this.familyName == other.familyName && - this.givenName == other.givenName && - this.ids == other.ids && - this.limit == other.limit && - this.orgName == other.orgName && - this.startingAfter == other.startingAfter && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is UserListParams && + this.email == other.email && + this.endingBefore == other.endingBefore && + this.familyName == other.familyName && + this.givenName == other.givenName && + this.ids == other.ids && + this.limit == other.limit && + this.orgName == other.orgName && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - email, - endingBefore, - familyName, - givenName, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + email, + endingBefore, + familyName, + givenName, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "UserListParams{email=$email, endingBefore=$endingBefore, familyName=$familyName, givenName=$givenName, ids=$ids, limit=$limit, orgName=$orgName, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -140,104 +172,132 @@ constructor( } /** - * 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(string: String) = apply { this.email = Email.ofString(string) } + fun email(string: String) = apply { + this.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 email(strings: List) = apply { this.email = Email.ofStrings(strings) } + fun email(strings: List) = apply { + this.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 + } /** - * 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(string: String) = apply { this.familyName = FamilyName.ofString(string) } + fun familyName(string: String) = apply { + this.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 familyName(strings: List) = apply { this.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(string: String) = apply { this.givenName = GivenName.ofString(string) } + fun givenName(string: String) = apply { + this.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 givenName(strings: List) = apply { this.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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** Filter search results to within a particular organization */ - fun orgName(orgName: String) = apply { this.orgName = orgName } + fun orgName(orgName: String) = apply { + this.orgName = orgName + } /** * Pagination cursor id. * - * For example, if the final item in the last page you fetched had an id of `foo`, pass - * `starting_after=foo` to fetch the next page. Note: you may only pass one of + * For example, if the final item in the last page you fetched had an 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 + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -277,84 +337,79 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): UserListParams = - UserListParams( - email, - endingBefore, - familyName, - givenName, - ids, - limit, - orgName, - startingAfter, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): UserListParams = UserListParams( + email, + endingBefore, + familyName, + givenName, + ids, + limit, + orgName, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } @JsonDeserialize(using = Email.Deserializer::class) @JsonSerialize(using = Email.Serializer::class) - class Email - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Email private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Email = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Email: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Email: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Email && this.string == other.string && this.strings == other.strings + return other is Email && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Email{string=$string}" - strings != null -> "Email{strings=$strings}" - _json != null -> "Email{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Email") - } + return when { + string != null -> "Email{string=$string}" + strings != null -> "Email{strings=$strings}" + _json != null -> "Email{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Email") + } } companion object { @@ -371,105 +426,93 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Email: $json") + throw BraintrustInvalidDataException("Unknown Email: $json") } } class Deserializer : BaseDeserializer(Email::class) { override fun ObjectCodec.deserialize(node: JsonNode): Email { - 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) - } - - return Email(_json = json) + 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) + } + + return Email(_json = json) } } 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") + } } } } @JsonDeserialize(using = FamilyName.Deserializer::class) @JsonSerialize(using = FamilyName.Serializer::class) - class FamilyName - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class FamilyName private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): FamilyName = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown FamilyName: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown FamilyName: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is FamilyName && - this.string == other.string && - this.strings == other.strings + return other is FamilyName && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "FamilyName{string=$string}" - strings != null -> "FamilyName{strings=$strings}" - _json != null -> "FamilyName{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FamilyName") - } + return when { + string != null -> "FamilyName{string=$string}" + strings != null -> "FamilyName{strings=$strings}" + _json != null -> "FamilyName{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FamilyName") + } } companion object { @@ -486,105 +529,93 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown FamilyName: $json") + throw BraintrustInvalidDataException("Unknown FamilyName: $json") } } class Deserializer : BaseDeserializer(FamilyName::class) { override fun ObjectCodec.deserialize(node: JsonNode): FamilyName { - 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) - } - - return FamilyName(_json = json) + 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) + } + + return FamilyName(_json = json) } } 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") + } } } } @JsonDeserialize(using = GivenName.Deserializer::class) @JsonSerialize(using = GivenName.Serializer::class) - class GivenName - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class GivenName private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): GivenName = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown GivenName: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown GivenName: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is GivenName && - this.string == other.string && - this.strings == other.strings + return other is GivenName && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "GivenName{string=$string}" - strings != null -> "GivenName{strings=$strings}" - _json != null -> "GivenName{_unknown=$_json}" - else -> throw IllegalStateException("Invalid GivenName") - } + return when { + string != null -> "GivenName{string=$string}" + strings != null -> "GivenName{strings=$strings}" + _json != null -> "GivenName{_unknown=$_json}" + else -> throw IllegalStateException("Invalid GivenName") + } } companion object { @@ -601,103 +632,93 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown GivenName: $json") + throw BraintrustInvalidDataException("Unknown GivenName: $json") } } class Deserializer : BaseDeserializer(GivenName::class) { override fun ObjectCodec.deserialize(node: JsonNode): GivenName { - 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) - } - - return GivenName(_json = json) + 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) + } + + return GivenName(_json = json) } } 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") + } } } } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -714,38 +735,34 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + override fun serialize(value: Ids, generator: JsonGenerator, provider: SerializerProvider) { + when { + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Ids") + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt index c2078548..b998a970 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/UserRetrieveParams.kt @@ -2,17 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.NoAutoDetect +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import java.util.Objects -class UserRetrieveParams -constructor( - private val userId: String, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, -) { +class UserRetrieveParams constructor(private val userId: String, private val additionalQueryParams: Map>, private val additionalHeaders: Map>, ) { fun userId(): String = userId @@ -21,10 +45,10 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> userId - else -> "" - } + return when (index) { + 0 -> userId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -32,26 +56,25 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserRetrieveParams && - this.userId == other.userId && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is UserRetrieveParams && + this.userId == other.userId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - userId, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + userId, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "UserRetrieveParams{userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "UserRetrieveParams{userId=$userId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -74,7 +97,9 @@ constructor( } /** User id */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String) = apply { + this.userId = userId + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -114,13 +139,16 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): UserRetrieveParams = - UserRetrieveParams( - checkNotNull(userId) { "`userId` is required but was not set" }, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): UserRetrieveParams = UserRetrieveParams( + checkNotNull(userId) { + "`userId` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/View.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/View.kt index bfc789b4..591eed71 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/View.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/View.kt @@ -2,37 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = View.Builder::class) @NoAutoDetect -class View -private constructor( - private val id: JsonField, - private val objectType: JsonField, - private val objectId: JsonField, - private val viewType: JsonField, - private val name: JsonField, - private val created: JsonField, - private val viewData: JsonField, - private val options: JsonField, - private val userId: JsonField, - private val deletedAt: JsonField, - private val additionalProperties: Map, +class View private constructor( + private val id: JsonField, + private val objectType: JsonField, + private val objectId: JsonField, + private val viewType: JsonField, + private val name: JsonField, + private val created: JsonField, + private val viewData: JsonField, + private val options: JsonField, + private val userId: JsonField, + private val deletedAt: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -70,34 +85,54 @@ private constructor( fun deletedAt(): OffsetDateTime? = deletedAt.getNullable("deleted_at") /** Unique identifier for the view */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") + @ExcludeMissing + fun _id() = id /** The object type that the ACL applies to */ - @JsonProperty("object_type") @ExcludeMissing fun _objectType() = objectType + @JsonProperty("object_type") + @ExcludeMissing + fun _objectType() = objectType /** The id of the object the view applies to */ - @JsonProperty("object_id") @ExcludeMissing fun _objectId() = objectId + @JsonProperty("object_id") + @ExcludeMissing + fun _objectId() = objectId /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") @ExcludeMissing fun _viewType() = viewType + @JsonProperty("view_type") + @ExcludeMissing + fun _viewType() = viewType /** Name of the view */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name() = name /** Date of view creation */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") + @ExcludeMissing + fun _created() = created /** The view definition */ - @JsonProperty("view_data") @ExcludeMissing fun _viewData() = viewData + @JsonProperty("view_data") + @ExcludeMissing + fun _viewData() = viewData /** Options for the view in the app */ - @JsonProperty("options") @ExcludeMissing fun _options() = options + @JsonProperty("options") + @ExcludeMissing + fun _options() = options /** Identifies the user who created the view */ - @JsonProperty("user_id") @ExcludeMissing fun _userId() = userId + @JsonProperty("user_id") + @ExcludeMissing + fun _userId() = userId /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") @ExcludeMissing fun _deletedAt() = deletedAt + @JsonProperty("deleted_at") + @ExcludeMissing + fun _deletedAt() = deletedAt @JsonAnyGetter @ExcludeMissing @@ -105,63 +140,61 @@ private constructor( fun validate(): View = apply { if (!validated) { - id() - objectType() - objectId() - viewType() - name() - created() - viewData()?.validate() - options()?.validate() - userId() - deletedAt() - validated = true + id() + objectType() + objectId() + viewType() + name() + created() + viewData()?.validate() + options()?.validate() + userId() + deletedAt() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is View && - this.id == other.id && - this.objectType == other.objectType && - this.objectId == other.objectId && - this.viewType == other.viewType && - this.name == other.name && - this.created == other.created && - this.viewData == other.viewData && - this.options == other.options && - this.userId == other.userId && - this.deletedAt == other.deletedAt && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is View && + this.id == other.id && + this.objectType == other.objectType && + this.objectId == other.objectId && + this.viewType == other.viewType && + this.name == other.name && + this.created == other.created && + this.viewData == other.viewData && + this.options == other.options && + this.userId == other.userId && + this.deletedAt == other.deletedAt && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - id, - objectType, - objectId, - viewType, - name, - created, - viewData, - options, - userId, - deletedAt, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + id, + objectType, + objectId, + viewType, + name, + created, + viewData, + options, + userId, + deletedAt, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "View{id=$id, objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, created=$created, viewData=$viewData, options=$options, userId=$userId, deletedAt=$deletedAt, additionalProperties=$additionalProperties}" + override fun toString() = "View{id=$id, objectType=$objectType, objectId=$objectId, viewType=$viewType, name=$name, created=$created, viewData=$viewData, options=$options, userId=$userId, deletedAt=$deletedAt, additionalProperties=$additionalProperties}" companion object { @@ -200,7 +233,11 @@ private constructor( fun id(id: String) = id(JsonField.of(id)) /** Unique identifier for the view */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { + this.id = id + } /** The object type that the ACL applies to */ fun objectType(objectType: ObjectType) = objectType(JsonField.of(objectType)) @@ -208,7 +245,9 @@ private constructor( /** The object type that the ACL applies to */ @JsonProperty("object_type") @ExcludeMissing - fun objectType(objectType: JsonField) = apply { this.objectType = objectType } + fun objectType(objectType: JsonField) = apply { + this.objectType = objectType + } /** The id of the object the view applies to */ fun objectId(objectId: String) = objectId(JsonField.of(objectId)) @@ -216,7 +255,9 @@ private constructor( /** The id of the object the view applies to */ @JsonProperty("object_id") @ExcludeMissing - fun objectId(objectId: JsonField) = apply { this.objectId = objectId } + fun objectId(objectId: JsonField) = apply { + this.objectId = objectId + } /** Type of table that the view corresponds to. */ fun viewType(viewType: ViewType) = viewType(JsonField.of(viewType)) @@ -224,7 +265,9 @@ private constructor( /** Type of table that the view corresponds to. */ @JsonProperty("view_type") @ExcludeMissing - fun viewType(viewType: JsonField) = apply { this.viewType = viewType } + fun viewType(viewType: JsonField) = apply { + this.viewType = viewType + } /** Name of the view */ fun name(name: String) = name(JsonField.of(name)) @@ -232,7 +275,9 @@ private constructor( /** Name of the view */ @JsonProperty("name") @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } + fun name(name: JsonField) = apply { + this.name = name + } /** Date of view creation */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -240,7 +285,9 @@ private constructor( /** Date of view creation */ @JsonProperty("created") @ExcludeMissing - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { + this.created = created + } /** The view definition */ fun viewData(viewData: ViewData) = viewData(JsonField.of(viewData)) @@ -248,7 +295,9 @@ private constructor( /** The view definition */ @JsonProperty("view_data") @ExcludeMissing - fun viewData(viewData: JsonField) = apply { this.viewData = viewData } + fun viewData(viewData: JsonField) = apply { + this.viewData = viewData + } /** Options for the view in the app */ fun options(options: ViewOptions) = options(JsonField.of(options)) @@ -256,7 +305,9 @@ private constructor( /** Options for the view in the app */ @JsonProperty("options") @ExcludeMissing - 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.of(userId)) @@ -264,7 +315,9 @@ private constructor( /** Identifies the user who created the view */ @JsonProperty("user_id") @ExcludeMissing - fun userId(userId: JsonField) = apply { this.userId = userId } + fun userId(userId: JsonField) = apply { + this.userId = userId + } /** Date of role deletion, or null if the role is still active */ fun deletedAt(deletedAt: OffsetDateTime) = deletedAt(JsonField.of(deletedAt)) @@ -272,7 +325,9 @@ private constructor( /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") @ExcludeMissing - fun deletedAt(deletedAt: JsonField) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: JsonField) = apply { + this.deletedAt = deletedAt + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -288,36 +343,33 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): View = - View( - id, - objectType, - objectId, - viewType, - name, - created, - viewData, - options, - userId, - deletedAt, - additionalProperties.toUnmodifiable(), - ) + fun build(): View = View( + id, + objectType, + objectId, + viewType, + name, + created, + viewData, + options, + userId, + deletedAt, + additionalProperties.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -380,55 +432,51 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ViewType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewType && this.value == other.value + return other is ViewType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -479,31 +527,29 @@ private constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } + fun value(): Value = when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt index 3691bdee..7fdf010b 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewCreateParams.kt @@ -2,35 +2,53 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ViewCreateParams constructor( + private val name: String, + private val objectId: String, + private val objectType: ObjectType?, + private val viewType: ViewType?, + private val deletedAt: OffsetDateTime?, + private val options: ViewOptions?, + private val userId: String?, + private val viewData: ViewData?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ViewCreateParams -constructor( - private val name: String, - private val objectId: String, - private val objectType: ObjectType?, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -50,17 +68,17 @@ constructor( fun viewData(): ViewData? = viewData internal fun getBody(): ViewCreateBody { - return ViewCreateBody( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalBodyProperties, - ) + return ViewCreateBody( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -69,44 +87,52 @@ constructor( @JsonDeserialize(builder = ViewCreateBody.Builder::class) @NoAutoDetect - class ViewCreateBody - internal constructor( - private val name: String?, - private val objectId: String?, - private val objectType: ObjectType?, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, - private val additionalProperties: Map, + class ViewCreateBody internal constructor( + private val name: String?, + private val objectId: String?, + private val objectType: ObjectType?, + private val viewType: ViewType?, + private val deletedAt: OffsetDateTime?, + private val options: ViewOptions?, + private val userId: String?, + private val viewData: ViewData?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the view */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** The id of the object the view applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") + fun objectId(): String? = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + fun objectType(): ObjectType? = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") fun viewType(): ViewType? = viewType + @JsonProperty("view_type") + fun viewType(): ViewType? = viewType /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") fun deletedAt(): OffsetDateTime? = deletedAt + @JsonProperty("deleted_at") + fun deletedAt(): OffsetDateTime? = deletedAt /** Options for the view in the app */ - @JsonProperty("options") fun options(): ViewOptions? = options + @JsonProperty("options") + fun options(): ViewOptions? = options /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(): String? = userId + @JsonProperty("user_id") + fun userId(): String? = userId /** The view definition */ - @JsonProperty("view_data") fun viewData(): ViewData? = viewData + @JsonProperty("view_data") + fun viewData(): ViewData? = viewData @JsonAnyGetter @ExcludeMissing @@ -115,42 +141,40 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewCreateBody && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ViewCreateBody && + this.name == other.name && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.viewType == other.viewType && + this.deletedAt == other.deletedAt && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = "ViewCreateBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" companion object { @@ -182,34 +206,52 @@ constructor( } /** Name of the view */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** The id of the object the view applies to */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { + this.objectType = objectType + } /** Type of table that the view corresponds to. */ @JsonProperty("view_type") - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType) = apply { + this.viewType = viewType + } /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") - fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: OffsetDateTime) = apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ @JsonProperty("options") - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: ViewOptions) = apply { + this.options = options + } /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + @JsonProperty("user_id") + fun userId(userId: String) = apply { + this.userId = userId + } /** The view definition */ @JsonProperty("view_data") - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: ViewData) = apply { + this.viewData = viewData + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -225,18 +267,21 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewCreateBody = - ViewCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalProperties.toUnmodifiable(), - ) + fun build(): ViewCreateBody = ViewCreateBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalProperties.toUnmodifiable(), + ) } } @@ -247,42 +292,41 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewCreateParams && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ViewCreateParams && + this.name == other.name && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.viewType == other.viewType && + this.deletedAt == other.deletedAt && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ViewCreateParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ViewCreateParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -321,28 +365,44 @@ constructor( } /** Name of the view */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** The id of the object the view 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 + } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType) = apply { + this.viewType = viewType + } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: OffsetDateTime) = apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: ViewOptions) = apply { + this.options = options + } /** Identifies the user who created the view */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String) = apply { + this.userId = userId + } /** The view definition */ - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: ViewData) = apply { + this.viewData = viewData + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -382,7 +442,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -393,41 +455,41 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ViewCreateParams = - ViewCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ViewCreateParams = ViewCreateParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -490,55 +552,51 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ViewType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewType && this.value == other.value + return other is ViewType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -589,31 +647,29 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } + fun known(): Known = when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt index f16e4697..4e6c342a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewData.kt @@ -2,26 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** The view definition */ @JsonDeserialize(builder = ViewData.Builder::class) @NoAutoDetect -class ViewData -private constructor( - private val search: JsonField, - private val additionalProperties: Map, -) { +class ViewData private constructor(private val search: JsonField, private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -29,7 +44,9 @@ private constructor( fun search(): ViewDataSearch? = search.getNullable("search") - @JsonProperty("search") @ExcludeMissing fun _search() = search + @JsonProperty("search") + @ExcludeMissing + fun _search() = search @JsonAnyGetter @ExcludeMissing @@ -37,28 +54,28 @@ private constructor( fun validate(): ViewData = apply { if (!validated) { - search()?.validate() - validated = true + search()?.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 other is ViewData && - this.search == other.search && - this.additionalProperties == other.additionalProperties + return other is ViewData && + this.search == other.search && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(search, additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(search, additionalProperties) + } + return hashCode } override fun toString() = "ViewData{search=$search, additionalProperties=$additionalProperties}" @@ -82,7 +99,9 @@ private constructor( @JsonProperty("search") @ExcludeMissing - fun search(search: JsonField) = apply { this.search = search } + fun search(search: JsonField) = apply { + this.search = search + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt index ea459fed..5bbf0b76 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewDataSearch.kt @@ -2,27 +2,46 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException @JsonDeserialize(builder = ViewDataSearch.Builder::class) @NoAutoDetect -class ViewDataSearch -private constructor( - private val filter: JsonField>, - private val tag: JsonField>, - private val match: JsonField>, - private val sort: JsonField>, - private val additionalProperties: Map, +class ViewDataSearch private constructor( + private val filter: JsonField>, + private val tag: JsonField>, + private val match: JsonField>, + private val sort: JsonField>, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -37,13 +56,21 @@ private constructor( fun sort(): List? = sort.getNullable("sort") - @JsonProperty("filter") @ExcludeMissing fun _filter() = filter + @JsonProperty("filter") + @ExcludeMissing + fun _filter() = filter - @JsonProperty("tag") @ExcludeMissing fun _tag() = tag + @JsonProperty("tag") + @ExcludeMissing + fun _tag() = tag - @JsonProperty("match") @ExcludeMissing fun _match() = match + @JsonProperty("match") + @ExcludeMissing + fun _match() = match - @JsonProperty("sort") @ExcludeMissing fun _sort() = sort + @JsonProperty("sort") + @ExcludeMissing + fun _sort() = sort @JsonAnyGetter @ExcludeMissing @@ -51,45 +78,43 @@ private constructor( fun validate(): ViewDataSearch = apply { if (!validated) { - filter() - tag() - match() - sort() - validated = true + filter() + tag() + match() + sort() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewDataSearch && - this.filter == other.filter && - this.tag == other.tag && - this.match == other.match && - this.sort == other.sort && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ViewDataSearch && + this.filter == other.filter && + this.tag == other.tag && + this.match == other.match && + this.sort == other.sort && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - filter, - tag, - match, - sort, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + filter, + tag, + match, + sort, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ViewDataSearch{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" + override fun toString() = "ViewDataSearch{filter=$filter, tag=$tag, match=$match, sort=$sort, additionalProperties=$additionalProperties}" companion object { @@ -116,25 +141,33 @@ private constructor( @JsonProperty("filter") @ExcludeMissing - fun filter(filter: JsonField>) = apply { this.filter = filter } + fun filter(filter: JsonField>) = apply { + this.filter = filter + } fun tag(tag: List) = tag(JsonField.of(tag)) @JsonProperty("tag") @ExcludeMissing - fun tag(tag: JsonField>) = apply { this.tag = tag } + fun tag(tag: JsonField>) = apply { + this.tag = tag + } fun match(match: List) = match(JsonField.of(match)) @JsonProperty("match") @ExcludeMissing - fun match(match: JsonField>) = apply { this.match = match } + fun match(match: JsonField>) = apply { + this.match = match + } fun sort(sort: List) = sort(JsonField.of(sort)) @JsonProperty("sort") @ExcludeMissing - fun sort(sort: JsonField>) = apply { this.sort = sort } + fun sort(sort: JsonField>) = apply { + this.sort = sort + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -150,13 +183,12 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewDataSearch = - ViewDataSearch( - filter.map { it.toUnmodifiable() }, - tag.map { it.toUnmodifiable() }, - match.map { it.toUnmodifiable() }, - sort.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) + fun build(): ViewDataSearch = ViewDataSearch( + filter.map { it.toUnmodifiable() }, + tag.map { it.toUnmodifiable() }, + match.map { it.toUnmodifiable() }, + sort.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt index 5b843dfa..4c54d45a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewDeleteParams.kt @@ -2,29 +2,48 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ViewDeleteParams constructor( + private val viewId: String, + private val objectId: String, + private val objectType: ObjectType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ViewDeleteParams -constructor( - private val viewId: String, - private val objectId: String, - private val objectType: ObjectType?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun viewId(): String = viewId @@ -34,11 +53,11 @@ constructor( fun objectType(): ObjectType? = objectType internal fun getBody(): ViewDeleteBody { - return ViewDeleteBody( - objectId, - objectType, - additionalBodyProperties, - ) + return ViewDeleteBody( + objectId, + objectType, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -46,28 +65,25 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } @JsonDeserialize(builder = ViewDeleteBody.Builder::class) @NoAutoDetect - class ViewDeleteBody - internal constructor( - private val objectId: String?, - private val objectType: ObjectType?, - private val additionalProperties: Map, - ) { + class ViewDeleteBody internal constructor(private val objectId: String?, private val objectType: ObjectType?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 /** The id of the object the view applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") + fun objectId(): String? = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + fun objectType(): ObjectType? = objectType @JsonAnyGetter @ExcludeMissing @@ -76,30 +92,28 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewDeleteBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ViewDeleteBody && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectId, - objectType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + objectId, + objectType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" + override fun toString() = "ViewDeleteBody{objectId=$objectId, objectType=$objectType, additionalProperties=$additionalProperties}" companion object { @@ -120,11 +134,15 @@ constructor( /** The id of the object the view applies to */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { + this.objectType = objectType + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -140,12 +158,13 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewDeleteBody = - ViewDeleteBody( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - additionalProperties.toUnmodifiable(), - ) + fun build(): ViewDeleteBody = ViewDeleteBody( + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + additionalProperties.toUnmodifiable(), + ) } } @@ -156,32 +175,31 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewDeleteParams && - this.viewId == other.viewId && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ViewDeleteParams && + this.viewId == other.viewId && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - viewId, - objectId, - objectType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + viewId, + objectId, + objectType, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ViewDeleteParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ViewDeleteParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -210,13 +228,19 @@ constructor( } /** 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 { 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 additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -256,7 +280,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -267,36 +293,36 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ViewDeleteParams = - ViewDeleteParams( - checkNotNull(viewId) { "`viewId` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ViewDeleteParams = ViewDeleteParams( + checkNotNull(viewId) { + "`viewId` is required but was not set" + }, + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -359,37 +385,35 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt index 137340ef..ea96251e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPage.kt @@ -2,97 +2,104 @@ package com.braintrustdata.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField import com.braintrustdata.api.core.NoAutoDetect import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.View import com.braintrustdata.api.services.blocking.ViewService -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import java.util.Objects -class ViewListPage -private constructor( - private val viewService: ViewService, - private val params: ViewListParams, - private val response: Response, -) { +class ViewListPage private constructor(private val viewService: ViewService, private val params: ViewListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewListPage && - this.viewService == other.viewService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ViewListPage && + this.viewService == other.viewService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - viewService, - params, - response, - ) + return Objects.hash( + viewService, + params, + response, + ) } - override fun toString() = - "ViewListPage{viewService=$viewService, params=$params, response=$response}" + override fun toString() = "ViewListPage{viewService=$viewService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ViewListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ViewListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - ViewListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ViewListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ViewListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } fun getNextPage(): ViewListPage? { - return getNextPageParams()?.let { viewService.list(it) } + return getNextPageParams()?.let { + viewService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(viewService: ViewService, params: ViewListParams, response: Response) = - ViewListPage( - viewService, - params, - response, - ) + fun of(viewService: ViewService, params: ViewListParams, response: Response) = ViewListPage( + viewService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -100,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ViewListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ViewListPage.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -153,20 +159,17 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ViewListPage, - ) : Sequence { + class AutoPager constructor(private val firstPage: ViewListPage, ) : Sequence { 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() ?: break - index = 0 + while (index < page.objects().size) { + yield(page.objects()[index++]) + } + page = page.getNextPage() ?: break + index = 0 } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt index 52c5becf..8a2fc62f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListPageAsync.kt @@ -2,99 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.services.async.ViewServiceAsync import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.Spliterator +import java.util.Spliterators +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate +import java.util.stream.Stream +import java.util.stream.StreamSupport import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.FlowCollector +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.models.View +import com.braintrustdata.api.services.async.ViewServiceAsync -class ViewListPageAsync -private constructor( - private val viewService: ViewServiceAsync, - private val params: ViewListParams, - private val response: Response, -) { +class ViewListPageAsync private constructor(private val viewService: ViewServiceAsync, private val params: ViewListParams, private val response: Response, ) { fun response(): Response = response fun objects(): List = response().objects() override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewListPageAsync && - this.viewService == other.viewService && - this.params == other.params && - this.response == other.response + if (this === other) { + return true + } + + return other is ViewListPageAsync && + this.viewService == other.viewService && + this.params == other.params && + this.response == other.response } override fun hashCode(): Int { - return Objects.hash( - viewService, - params, - response, - ) + return Objects.hash( + viewService, + params, + response, + ) } - override fun toString() = - "ViewListPageAsync{viewService=$viewService, params=$params, response=$response}" + override fun toString() = "ViewListPageAsync{viewService=$viewService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !objects().isEmpty() + return !objects().isEmpty() } fun getNextPageParams(): ViewListParams? { - if (!hasNextPage()) { - return null - } - - return if (params.endingBefore() != null) { - ViewListParams.builder().from(params).endingBefore(objects().first().id()).build() - } else { - ViewListParams.builder().from(params).startingAfter(objects().last().id()).build() - } + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ViewListParams.builder().from(params).endingBefore(objects().first().id()).build(); + } else { + ViewListParams.builder().from(params).startingAfter(objects().last().id()).build(); + } } suspend fun getNextPage(): ViewListPageAsync? { - return getNextPageParams()?.let { viewService.list(it) } + return getNextPageParams()?.let { + viewService.list(it) + } } fun autoPager(): AutoPager = AutoPager(this) companion object { - fun of(viewService: ViewServiceAsync, params: ViewListParams, response: Response) = - ViewListPageAsync( - viewService, - params, - response, - ) + fun of(viewService: ViewServiceAsync, params: ViewListParams, response: Response) = ViewListPageAsync( + viewService, + params, + response, + ) } @JsonDeserialize(builder = Response.Builder::class) @NoAutoDetect - class Response - constructor( - private val objects: JsonField>, - private val additionalProperties: Map, - ) { + class Response constructor(private val objects: JsonField>, private val additionalProperties: Map, ) { private var validated: Boolean = false fun objects(): List = objects.getNullable("objects") ?: listOf() - @JsonProperty("objects") fun _objects(): JsonField>? = objects + @JsonProperty("objects") + fun _objects(): JsonField>? = objects @JsonAnyGetter @ExcludeMissing @@ -102,29 +107,28 @@ private constructor( fun validate(): Response = apply { if (!validated) { - 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 other is Response && - this.objects == other.objects && - this.additionalProperties == other.additionalProperties + return other is Response && + this.objects == other.objects && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - return Objects.hash(objects, additionalProperties) + return Objects.hash(objects, additionalProperties) } - override fun toString() = - "ViewListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" + override fun toString() = "ViewListPageAsync.Response{objects=$objects, additionalProperties=$additionalProperties}" companion object { @@ -155,21 +159,18 @@ private constructor( } } - class AutoPager - constructor( - private val firstPage: ViewListPageAsync, - ) : Flow { + class AutoPager constructor(private val firstPage: ViewListPageAsync, ) : Flow { override suspend fun collect(collector: FlowCollector) { - var page = firstPage - var index = 0 - while (true) { - while (index < page.objects().size) { - collector.emit(page.objects()[index++]) - } - page = page.getNextPage() ?: break - index = 0 + var page = firstPage + var index = 0 + while (true) { + while (index < page.objects().size) { + collector.emit(page.objects()[index++]) } + page = page.getNextPage() ?: break + index = 0 + } } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt index 95deac6a..8580f553 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewListParams.kt @@ -2,38 +2,52 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.BaseDeserializer -import com.braintrustdata.api.core.BaseSerializer -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.getOrThrow -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.core.JsonGenerator import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ViewListParams constructor( + private val objectId: String, + private val objectType: ObjectType?, + private val endingBefore: String?, + private val ids: Ids?, + private val limit: Long?, + private val startingAfter: String?, + private val viewName: String?, + private val viewType: ViewType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, -class ViewListParams -constructor( - private val objectId: String, - private val objectType: ObjectType?, - private val endingBefore: String?, - private val ids: Ids?, - private val limit: Long?, - private val startingAfter: String?, - private val viewName: String?, - private val viewType: ViewType?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, ) { fun objectId(): String = objectId @@ -53,17 +67,33 @@ constructor( fun viewType(): ViewType? = viewType internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.objectId.let { params.put("object_id", listOf(it.toString())) } - this.objectType.let { params.put("object_type", listOf(it.toString())) } - this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } - this.ids?.let { params.put("ids", listOf(it.toString())) } - this.limit?.let { params.put("limit", listOf(it.toString())) } - this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } - this.viewName?.let { params.put("view_name", listOf(it.toString())) } - this.viewType?.let { params.put("view_type", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.objectId.let { + params.put("object_id", listOf(it.toString())) + } + this.objectType.let { + params.put("object_type", listOf(it.toString())) + } + this.endingBefore?.let { + params.put("ending_before", listOf(it.toString())) + } + this.ids?.let { + params.put("ids", listOf(it.toString())) + } + this.limit?.let { + params.put("limit", listOf(it.toString())) + } + this.startingAfter?.let { + params.put("starting_after", listOf(it.toString())) + } + this.viewName?.let { + params.put("view_name", listOf(it.toString())) + } + this.viewType?.let { + params.put("view_type", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders @@ -73,40 +103,39 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewListParams && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.endingBefore == other.endingBefore && - this.ids == other.ids && - this.limit == other.limit && - this.startingAfter == other.startingAfter && - this.viewName == other.viewName && - this.viewType == other.viewType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ViewListParams && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.endingBefore == other.endingBefore && + this.ids == other.ids && + this.limit == other.limit && + this.startingAfter == other.startingAfter && + this.viewName == other.viewName && + this.viewType == other.viewType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - objectId, - objectType, - endingBefore, - ids, - limit, - startingAfter, - viewName, - viewType, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + objectId, + objectType, + endingBefore, + ids, + limit, + startingAfter, + viewName, + viewType, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ViewListParams{objectId=$objectId, objectType=$objectType, endingBefore=$endingBefore, ids=$ids, limit=$limit, startingAfter=$startingAfter, viewName=$viewName, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -143,55 +172,75 @@ constructor( } /** 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 + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * 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(string: String) = apply { this.ids = Ids.ofString(string) } + fun ids(string: String) = apply { + this.ids = Ids.ofString(string) + } /** - * Filter search results to a particular set of object IDs. To specify a list of IDs, - * include the query param multiple times + * Filter search results to a particular set of object IDs. To specify a list of + * IDs, include the query param multiple times */ - fun ids(strings: List) = apply { this.ids = Ids.ofStrings(strings) } + fun ids(strings: List) = apply { + this.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 + } /** * 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 + } /** Name of the view to search for */ - fun viewName(viewName: String) = apply { this.viewName = viewName } + fun viewName(viewName: String) = apply { + this.viewName = viewName + } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType) = apply { + this.viewType = viewType + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -231,37 +280,38 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } - - fun build(): ViewListParams = - ViewListParams( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - endingBefore, - ids, - limit, - startingAfter, - viewName, - viewType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } + + fun build(): ViewListParams = ViewListParams( + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + endingBefore, + ids, + limit, + startingAfter, + viewName, + viewType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -324,102 +374,94 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } @JsonDeserialize(using = Ids.Deserializer::class) @JsonSerialize(using = Ids.Serializer::class) - class Ids - private constructor( - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { + class Ids private constructor(private val string: String? = null, private val strings: List? = null, private val _json: JsonValue? = null, ) { private var validated: Boolean = false fun string(): String? = string - fun strings(): List? = strings fun isString(): Boolean = string != null - fun isStrings(): Boolean = strings != null fun asString(): String = string.getOrThrow("string") - fun asStrings(): List = strings.getOrThrow("strings") fun _json(): JsonValue? = _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) + } } fun validate(): Ids = apply { if (!validated) { - if (string == null && strings == null) { - throw BraintrustInvalidDataException("Unknown Ids: $_json") - } - validated = true + if (string == null && strings == null) { + throw BraintrustInvalidDataException("Unknown Ids: $_json") + } + validated = true } } override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is Ids && this.string == other.string && this.strings == other.strings + return other is Ids && + this.string == other.string && + this.strings == other.strings } override fun hashCode(): Int { - return Objects.hash(string, strings) + return Objects.hash(string, strings) } override fun toString(): String { - return when { - string != null -> "Ids{string=$string}" - strings != null -> "Ids{strings=$strings}" - _json != null -> "Ids{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Ids") - } + return when { + string != null -> "Ids{string=$string}" + strings != null -> "Ids{strings=$strings}" + _json != null -> "Ids{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Ids") + } } companion object { @@ -436,56 +478,50 @@ constructor( fun visitStrings(strings: List): T fun unknown(json: JsonValue?): T { - throw BraintrustInvalidDataException("Unknown Ids: $json") + throw BraintrustInvalidDataException("Unknown Ids: $json") } } class Deserializer : BaseDeserializer(Ids::class) { override fun ObjectCodec.deserialize(node: JsonNode): Ids { - val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Ids(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Ids(strings = it, _json = json) - } - - return Ids(_json = json) + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Ids(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Ids(strings = it, _json = json) + } + + return Ids(_json = json) } } class Serializer : BaseSerializer(Ids::class) { - override fun serialize( - value: Ids, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Ids") - } + 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") + } } } } - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ViewType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewType && this.value == other.value + return other is ViewType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -536,31 +572,29 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } + fun known(): Known = when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt index 8bceb058..42e9071f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewOptions.kt @@ -2,27 +2,46 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonMissing -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException /** Options for the view in the app */ @JsonDeserialize(builder = ViewOptions.Builder::class) @NoAutoDetect -class ViewOptions -private constructor( - private val columnVisibility: JsonField, - private val columnOrder: JsonField>, - private val columnSizing: JsonField, - private val additionalProperties: Map, +class ViewOptions private constructor( + private val columnVisibility: JsonField, + private val columnOrder: JsonField>, + private val columnSizing: JsonField, + private val additionalProperties: Map, + ) { private var validated: Boolean = false @@ -35,11 +54,17 @@ private constructor( fun columnSizing(): ColumnSizing? = columnSizing.getNullable("columnSizing") - @JsonProperty("columnVisibility") @ExcludeMissing fun _columnVisibility() = columnVisibility + @JsonProperty("columnVisibility") + @ExcludeMissing + fun _columnVisibility() = columnVisibility - @JsonProperty("columnOrder") @ExcludeMissing fun _columnOrder() = columnOrder + @JsonProperty("columnOrder") + @ExcludeMissing + fun _columnOrder() = columnOrder - @JsonProperty("columnSizing") @ExcludeMissing fun _columnSizing() = columnSizing + @JsonProperty("columnSizing") + @ExcludeMissing + fun _columnSizing() = columnSizing @JsonAnyGetter @ExcludeMissing @@ -47,42 +72,40 @@ private constructor( fun validate(): ViewOptions = apply { if (!validated) { - columnVisibility()?.validate() - columnOrder() - columnSizing()?.validate() - validated = true + columnVisibility()?.validate() + columnOrder() + columnSizing()?.validate() + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewOptions && - this.columnVisibility == other.columnVisibility && - this.columnOrder == other.columnOrder && - this.columnSizing == other.columnSizing && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ViewOptions && + this.columnVisibility == other.columnVisibility && + this.columnOrder == other.columnOrder && + this.columnSizing == other.columnSizing && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - columnVisibility, - columnOrder, - columnSizing, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + columnVisibility, + columnOrder, + columnSizing, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ViewOptions{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" + override fun toString() = "ViewOptions{columnVisibility=$columnVisibility, columnOrder=$columnOrder, columnSizing=$columnSizing, additionalProperties=$additionalProperties}" companion object { @@ -103,8 +126,7 @@ private constructor( additionalProperties(viewOptions.additionalProperties) } - fun columnVisibility(columnVisibility: ColumnVisibility) = - columnVisibility(JsonField.of(columnVisibility)) + fun columnVisibility(columnVisibility: ColumnVisibility) = columnVisibility(JsonField.of(columnVisibility)) @JsonProperty("columnVisibility") @ExcludeMissing @@ -142,21 +164,17 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewOptions = - ViewOptions( - columnVisibility, - columnOrder.map { it.toUnmodifiable() }, - columnSizing, - additionalProperties.toUnmodifiable(), - ) + fun build(): ViewOptions = ViewOptions( + columnVisibility, + columnOrder.map { it.toUnmodifiable() }, + columnSizing, + additionalProperties.toUnmodifiable(), + ) } @JsonDeserialize(builder = ColumnSizing.Builder::class) @NoAutoDetect - class ColumnSizing - private constructor( - private val additionalProperties: Map, - ) { + class ColumnSizing private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -168,25 +186,26 @@ private constructor( fun validate(): ColumnSizing = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ColumnSizing && this.additionalProperties == other.additionalProperties + return other is ColumnSizing && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ColumnSizing{additionalProperties=$additionalProperties}" @@ -224,10 +243,7 @@ private constructor( @JsonDeserialize(builder = ColumnVisibility.Builder::class) @NoAutoDetect - class ColumnVisibility - private constructor( - private val additionalProperties: Map, - ) { + class ColumnVisibility private constructor(private val additionalProperties: Map, ) { private var validated: Boolean = false @@ -239,26 +255,26 @@ private constructor( fun validate(): ColumnVisibility = apply { if (!validated) { - validated = true + validated = true } } fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ColumnVisibility && - this.additionalProperties == other.additionalProperties + return other is ColumnVisibility && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = Objects.hash(additionalProperties) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode } override fun toString() = "ColumnVisibility{additionalProperties=$additionalProperties}" diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt index 12d9a58b..8c835111 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewReplaceParams.kt @@ -2,35 +2,53 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ViewReplaceParams constructor( + private val name: String, + private val objectId: String, + private val objectType: ObjectType?, + private val viewType: ViewType?, + private val deletedAt: OffsetDateTime?, + private val options: ViewOptions?, + private val userId: String?, + private val viewData: ViewData?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ViewReplaceParams -constructor( - private val name: String, - private val objectId: String, - private val objectType: ObjectType?, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun name(): String = name @@ -50,17 +68,17 @@ constructor( fun viewData(): ViewData? = viewData internal fun getBody(): ViewReplaceBody { - return ViewReplaceBody( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalBodyProperties, - ) + return ViewReplaceBody( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -69,44 +87,52 @@ constructor( @JsonDeserialize(builder = ViewReplaceBody.Builder::class) @NoAutoDetect - class ViewReplaceBody - internal constructor( - private val name: String?, - private val objectId: String?, - private val objectType: ObjectType?, - private val viewType: ViewType?, - private val deletedAt: OffsetDateTime?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, - private val additionalProperties: Map, + class ViewReplaceBody internal constructor( + private val name: String?, + private val objectId: String?, + private val objectType: ObjectType?, + private val viewType: ViewType?, + private val deletedAt: OffsetDateTime?, + private val options: ViewOptions?, + private val userId: String?, + private val viewData: ViewData?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** Name of the view */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** The id of the object the view applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") + fun objectId(): String? = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + fun objectType(): ObjectType? = objectType /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") fun viewType(): ViewType? = viewType + @JsonProperty("view_type") + fun viewType(): ViewType? = viewType /** Date of role deletion, or null if the role is still active */ - @JsonProperty("deleted_at") fun deletedAt(): OffsetDateTime? = deletedAt + @JsonProperty("deleted_at") + fun deletedAt(): OffsetDateTime? = deletedAt /** Options for the view in the app */ - @JsonProperty("options") fun options(): ViewOptions? = options + @JsonProperty("options") + fun options(): ViewOptions? = options /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(): String? = userId + @JsonProperty("user_id") + fun userId(): String? = userId /** The view definition */ - @JsonProperty("view_data") fun viewData(): ViewData? = viewData + @JsonProperty("view_data") + fun viewData(): ViewData? = viewData @JsonAnyGetter @ExcludeMissing @@ -115,42 +141,40 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewReplaceBody && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ViewReplaceBody && + this.name == other.name && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.viewType == other.viewType && + this.deletedAt == other.deletedAt && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" + override fun toString() = "ViewReplaceBody{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalProperties=$additionalProperties}" companion object { @@ -182,34 +206,52 @@ constructor( } /** Name of the view */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** The id of the object the view applies to */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { + this.objectType = objectType + } /** Type of table that the view corresponds to. */ @JsonProperty("view_type") - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType) = apply { + this.viewType = viewType + } /** Date of role deletion, or null if the role is still active */ @JsonProperty("deleted_at") - fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: OffsetDateTime) = apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ @JsonProperty("options") - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: ViewOptions) = apply { + this.options = options + } /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + @JsonProperty("user_id") + fun userId(userId: String) = apply { + this.userId = userId + } /** The view definition */ @JsonProperty("view_data") - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: ViewData) = apply { + this.viewData = viewData + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -225,18 +267,21 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewReplaceBody = - ViewReplaceBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalProperties.toUnmodifiable(), - ) + fun build(): ViewReplaceBody = ViewReplaceBody( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalProperties.toUnmodifiable(), + ) } } @@ -247,42 +292,41 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewReplaceParams && - this.name == other.name && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.viewType == other.viewType && - this.deletedAt == other.deletedAt && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ViewReplaceParams && + this.name == other.name && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.viewType == other.viewType && + this.deletedAt == other.deletedAt && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - name, - objectId, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + name, + objectId, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ViewReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ViewReplaceParams{name=$name, objectId=$objectId, objectType=$objectType, viewType=$viewType, deletedAt=$deletedAt, options=$options, userId=$userId, viewData=$viewData, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -321,28 +365,44 @@ constructor( } /** Name of the view */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** The id of the object the view 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 + } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType) = apply { + this.viewType = viewType + } /** Date of role deletion, or null if the role is still active */ - fun deletedAt(deletedAt: OffsetDateTime) = apply { this.deletedAt = deletedAt } + fun deletedAt(deletedAt: OffsetDateTime) = apply { + this.deletedAt = deletedAt + } /** Options for the view in the app */ - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: ViewOptions) = apply { + this.options = options + } /** Identifies the user who created the view */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String) = apply { + this.userId = userId + } /** The view definition */ - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: ViewData) = apply { + this.viewData = viewData + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -382,7 +442,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -393,41 +455,41 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ViewReplaceParams = - ViewReplaceParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - viewType, - deletedAt, - options, - userId, - viewData, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ViewReplaceParams = ViewReplaceParams( + checkNotNull(name) { + "`name` is required but was not set" + }, + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + viewType, + deletedAt, + options, + userId, + viewData, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -490,55 +552,51 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ViewType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewType && this.value == other.value + return other is ViewType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -589,31 +647,29 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } + fun known(): Known = when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt index ea5f35fb..2c25ad45 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewRetrieveParams.kt @@ -2,23 +2,47 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.* -import com.fasterxml.jackson.annotation.JsonCreator -import java.util.Objects -class ViewRetrieveParams -constructor( - private val viewId: String, - private val objectId: String, - private val objectType: ObjectType?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, +class ViewRetrieveParams constructor( + private val viewId: String, + private val objectId: String, + private val objectType: ObjectType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + ) { fun viewId(): String = viewId @@ -28,20 +52,24 @@ constructor( fun objectType(): ObjectType? = objectType internal fun getQueryParams(): Map> { - val params = mutableMapOf>() - this.objectId.let { params.put("object_id", listOf(it.toString())) } - this.objectType.let { params.put("object_type", listOf(it.toString())) } - params.putAll(additionalQueryParams) - return params.toUnmodifiable() + val params = mutableMapOf>() + this.objectId.let { + params.put("object_id", listOf(it.toString())) + } + this.objectType.let { + params.put("object_type", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() } internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } fun _additionalQueryParams(): Map> = additionalQueryParams @@ -49,30 +77,29 @@ constructor( fun _additionalHeaders(): Map> = additionalHeaders override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewRetrieveParams && - this.viewId == other.viewId && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders + if (this === other) { + return true + } + + return other is ViewRetrieveParams && + this.viewId == other.viewId && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders } override fun hashCode(): Int { - return Objects.hash( - viewId, - objectId, - objectType, - additionalQueryParams, - additionalHeaders, - ) + return Objects.hash( + viewId, + objectId, + objectType, + additionalQueryParams, + additionalHeaders, + ) } - override fun toString() = - "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + override fun toString() = "ViewRetrieveParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" fun toBuilder() = Builder().from(this) @@ -99,13 +126,19 @@ constructor( } /** 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 additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -145,32 +178,35 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } - fun build(): ViewRetrieveParams = - ViewRetrieveParams( - checkNotNull(viewId) { "`viewId` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - ) + fun build(): ViewRetrieveParams = ViewRetrieveParams( + checkNotNull(viewId) { + "`viewId` is required but was not set" + }, + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -233,37 +269,35 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } + + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt deleted file mode 100755 index 83379d54..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewType.kt +++ /dev/null @@ -1,102 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator - -class ViewType -@JsonCreator -private constructor( - private val value: JsonField, -) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewType && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val PROJECTS = ViewType(JsonField.of("projects")) - - val LOGS = ViewType(JsonField.of("logs")) - - val EXPERIMENTS = ViewType(JsonField.of("experiments")) - - val DATASETS = ViewType(JsonField.of("datasets")) - - val PROMPTS = ViewType(JsonField.of("prompts")) - - val PLAYGROUNDS = ViewType(JsonField.of("playgrounds")) - - val EXPERIMENT = ViewType(JsonField.of("experiment")) - - val DATASET = ViewType(JsonField.of("dataset")) - - fun of(value: String) = ViewType(JsonField.of(value)) - } - - enum class Known { - PROJECTS, - LOGS, - EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, - EXPERIMENT, - DATASET, - } - - enum class Value { - PROJECTS, - LOGS, - EXPERIMENTS, - DATASETS, - PROMPTS, - PLAYGROUNDS, - EXPERIMENT, - DATASET, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } - - fun asString(): String = _value().asStringOrThrow() -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt index 23136ac8..e5f1a232 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/models/ViewUpdateParams.kt @@ -2,34 +2,53 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.Enum -import com.braintrustdata.api.core.ExcludeMissing -import com.braintrustdata.api.core.JsonField -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.NoAutoDetect -import com.braintrustdata.api.core.toUnmodifiable -import com.braintrustdata.api.errors.BraintrustInvalidDataException -import com.braintrustdata.api.models.* import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.apache.hc.core5.http.ContentType +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter import java.util.Objects +import java.util.Optional +import java.util.UUID +import com.braintrustdata.api.core.BaseDeserializer +import com.braintrustdata.api.core.BaseSerializer +import com.braintrustdata.api.core.getOrThrow +import com.braintrustdata.api.core.ExcludeMissing +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonMissing +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.core.toUnmodifiable +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.* + +class ViewUpdateParams constructor( + private val viewId: String, + private val objectId: String, + private val objectType: ObjectType?, + private val name: String?, + private val options: ViewOptions?, + private val userId: String?, + private val viewData: ViewData?, + private val viewType: ViewType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, -class ViewUpdateParams -constructor( - private val viewId: String, - private val objectId: String, - private val objectType: ObjectType?, - private val name: String?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, - private val viewType: ViewType?, - private val additionalQueryParams: Map>, - private val additionalHeaders: Map>, - private val additionalBodyProperties: Map, ) { fun viewId(): String = viewId @@ -49,16 +68,16 @@ constructor( fun viewType(): ViewType? = viewType internal fun getBody(): ViewUpdateBody { - return ViewUpdateBody( - objectId, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalBodyProperties, - ) + return ViewUpdateBody( + objectId, + objectType, + name, + options, + userId, + viewData, + viewType, + additionalBodyProperties, + ) } internal fun getQueryParams(): Map> = additionalQueryParams @@ -66,48 +85,55 @@ constructor( internal fun getHeaders(): Map> = additionalHeaders fun getPathParam(index: Int): String { - return when (index) { - 0 -> viewId - else -> "" - } + return when (index) { + 0 -> viewId + else -> "" + } } @JsonDeserialize(builder = ViewUpdateBody.Builder::class) @NoAutoDetect - class ViewUpdateBody - internal constructor( - private val objectId: String?, - private val objectType: ObjectType?, - private val name: String?, - private val options: ViewOptions?, - private val userId: String?, - private val viewData: ViewData?, - private val viewType: ViewType?, - private val additionalProperties: Map, + class ViewUpdateBody internal constructor( + private val objectId: String?, + private val objectType: ObjectType?, + private val name: String?, + private val options: ViewOptions?, + private val userId: String?, + private val viewData: ViewData?, + private val viewType: ViewType?, + private val additionalProperties: Map, + ) { private var hashCode: Int = 0 /** The id of the object the view applies to */ - @JsonProperty("object_id") fun objectId(): String? = objectId + @JsonProperty("object_id") + fun objectId(): String? = objectId /** The object type that the ACL applies to */ - @JsonProperty("object_type") fun objectType(): ObjectType? = objectType + @JsonProperty("object_type") + fun objectType(): ObjectType? = objectType /** Name of the view */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") + fun name(): String? = name /** Options for the view in the app */ - @JsonProperty("options") fun options(): ViewOptions? = options + @JsonProperty("options") + fun options(): ViewOptions? = options /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(): String? = userId + @JsonProperty("user_id") + fun userId(): String? = userId /** The view definition */ - @JsonProperty("view_data") fun viewData(): ViewData? = viewData + @JsonProperty("view_data") + fun viewData(): ViewData? = viewData /** Type of table that the view corresponds to. */ - @JsonProperty("view_type") fun viewType(): ViewType? = viewType + @JsonProperty("view_type") + fun viewType(): ViewType? = viewType @JsonAnyGetter @ExcludeMissing @@ -116,40 +142,38 @@ constructor( fun toBuilder() = Builder().from(this) override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewUpdateBody && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.name == other.name && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.viewType == other.viewType && - this.additionalProperties == other.additionalProperties + if (this === other) { + return true + } + + return other is ViewUpdateBody && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.name == other.name && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.viewType == other.viewType && + this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - objectId, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalProperties, - ) - } - return hashCode + if (hashCode == 0) { + hashCode = Objects.hash( + objectId, + objectType, + name, + options, + userId, + viewData, + viewType, + additionalProperties, + ) + } + return hashCode } - override fun toString() = - "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" + override fun toString() = "ViewUpdateBody{objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalProperties=$additionalProperties}" companion object { @@ -180,29 +204,45 @@ constructor( /** The id of the object the view applies to */ @JsonProperty("object_id") - fun objectId(objectId: String) = apply { this.objectId = objectId } + fun objectId(objectId: String) = apply { + this.objectId = objectId + } /** The object type that the ACL applies to */ @JsonProperty("object_type") - fun objectType(objectType: ObjectType) = apply { this.objectType = objectType } + fun objectType(objectType: ObjectType) = apply { + this.objectType = objectType + } /** Name of the view */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } + @JsonProperty("name") + fun name(name: String) = apply { + this.name = name + } /** Options for the view in the app */ @JsonProperty("options") - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: ViewOptions) = apply { + this.options = options + } /** Identifies the user who created the view */ - @JsonProperty("user_id") fun userId(userId: String) = apply { this.userId = userId } + @JsonProperty("user_id") + fun userId(userId: String) = apply { + this.userId = userId + } /** The view definition */ @JsonProperty("view_data") - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: ViewData) = apply { + this.viewData = viewData + } /** Type of table that the view corresponds to. */ @JsonProperty("view_type") - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType) = apply { + this.viewType = viewType + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -218,17 +258,18 @@ constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): ViewUpdateBody = - ViewUpdateBody( - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalProperties.toUnmodifiable(), - ) + fun build(): ViewUpdateBody = ViewUpdateBody( + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + name, + options, + userId, + viewData, + viewType, + additionalProperties.toUnmodifiable(), + ) } } @@ -239,42 +280,41 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ViewUpdateParams && - this.viewId == other.viewId && - this.objectId == other.objectId && - this.objectType == other.objectType && - this.name == other.name && - this.options == other.options && - this.userId == other.userId && - this.viewData == other.viewData && - this.viewType == other.viewType && - this.additionalQueryParams == other.additionalQueryParams && - this.additionalHeaders == other.additionalHeaders && - this.additionalBodyProperties == other.additionalBodyProperties + if (this === other) { + return true + } + + return other is ViewUpdateParams && + this.viewId == other.viewId && + this.objectId == other.objectId && + this.objectType == other.objectType && + this.name == other.name && + this.options == other.options && + this.userId == other.userId && + this.viewData == other.viewData && + this.viewType == other.viewType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int { - return Objects.hash( - viewId, - objectId, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalQueryParams, - additionalHeaders, - additionalBodyProperties, - ) + return Objects.hash( + viewId, + objectId, + objectType, + name, + options, + userId, + viewData, + viewType, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) } - override fun toString() = - "ViewUpdateParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + override fun toString() = "ViewUpdateParams{viewId=$viewId, objectId=$objectId, objectType=$objectType, name=$name, options=$options, userId=$userId, viewData=$viewData, viewType=$viewType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -313,28 +353,44 @@ constructor( } /** 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 { 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 + } /** Name of the view */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = apply { + this.name = name + } /** Options for the view in the app */ - fun options(options: ViewOptions) = apply { this.options = options } + fun options(options: ViewOptions) = apply { + this.options = options + } /** Identifies the user who created the view */ - fun userId(userId: String) = apply { this.userId = userId } + fun userId(userId: String) = apply { + this.userId = userId + } /** The view definition */ - fun viewData(viewData: ViewData) = apply { this.viewData = viewData } + fun viewData(viewData: ViewData) = apply { + this.viewData = viewData + } /** Type of table that the view corresponds to. */ - fun viewType(viewType: ViewType) = apply { this.viewType = viewType } + fun viewType(viewType: ViewType) = apply { + this.viewType = viewType + } fun additionalQueryParams(additionalQueryParams: Map>) = apply { this.additionalQueryParams.clear() @@ -374,7 +430,9 @@ constructor( additionalHeaders.forEach(this::putHeaders) } - fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + fun removeHeader(name: String) = apply { + this.additionalHeaders.put(name, mutableListOf()) + } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { this.additionalBodyProperties.clear() @@ -385,41 +443,41 @@ constructor( this.additionalBodyProperties.put(key, value) } - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } - fun build(): ViewUpdateParams = - ViewUpdateParams( - checkNotNull(viewId) { "`viewId` is required but was not set" }, - checkNotNull(objectId) { "`objectId` is required but was not set" }, - objectType, - name, - options, - userId, - viewData, - viewType, - additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), - additionalBodyProperties.toUnmodifiable(), - ) + fun build(): ViewUpdateParams = ViewUpdateParams( + checkNotNull(viewId) { + "`viewId` is required but was not set" + }, + checkNotNull(objectId) { + "`objectId` is required but was not set" + }, + objectType, + name, + options, + userId, + viewData, + viewType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) } - class ObjectType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ObjectType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ObjectType && this.value == other.value + return other is ObjectType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -482,55 +540,51 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - ORGANIZATION -> Value.ORGANIZATION - PROJECT -> Value.PROJECT - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - PROMPT -> Value.PROMPT - PROMPT_SESSION -> Value.PROMPT_SESSION - GROUP -> Value.GROUP - ROLE -> Value.ROLE - ORG_MEMBER -> Value.ORG_MEMBER - PROJECT_LOG -> Value.PROJECT_LOG - ORG_PROJECT -> Value.ORG_PROJECT - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + ORGANIZATION -> Value.ORGANIZATION + PROJECT -> Value.PROJECT + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + PROMPT -> Value.PROMPT + PROMPT_SESSION -> Value.PROMPT_SESSION + GROUP -> Value.GROUP + ROLE -> Value.ROLE + ORG_MEMBER -> Value.ORG_MEMBER + PROJECT_LOG -> Value.PROJECT_LOG + ORG_PROJECT -> Value.ORG_PROJECT + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - ORGANIZATION -> Known.ORGANIZATION - PROJECT -> Known.PROJECT - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - PROMPT -> Known.PROMPT - PROMPT_SESSION -> Known.PROMPT_SESSION - GROUP -> Known.GROUP - ROLE -> Known.ROLE - ORG_MEMBER -> Known.ORG_MEMBER - PROJECT_LOG -> Known.PROJECT_LOG - ORG_PROJECT -> Known.ORG_PROJECT - else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") - } + fun known(): Known = when (this) { + ORGANIZATION -> Known.ORGANIZATION + PROJECT -> Known.PROJECT + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + PROMPT -> Known.PROMPT + PROMPT_SESSION -> Known.PROMPT_SESSION + GROUP -> Known.GROUP + ROLE -> Known.ROLE + ORG_MEMBER -> Known.ORG_MEMBER + PROJECT_LOG -> Known.PROJECT_LOG + ORG_PROJECT -> Known.ORG_PROJECT + else -> throw BraintrustInvalidDataException("Unknown ObjectType: $value") + } fun asString(): String = _value().asStringOrThrow() } - class ViewType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + class ViewType @JsonCreator private constructor(private val value: JsonField, ) : Enum { - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + if (this === other) { + return true + } - return other is ViewType && this.value == other.value + return other is ViewType && + this.value == other.value } override fun hashCode() = value.hashCode() @@ -581,31 +635,29 @@ constructor( _UNKNOWN, } - fun value(): Value = - when (this) { - PROJECTS -> Value.PROJECTS - LOGS -> Value.LOGS - EXPERIMENTS -> Value.EXPERIMENTS - DATASETS -> Value.DATASETS - PROMPTS -> Value.PROMPTS - PLAYGROUNDS -> Value.PLAYGROUNDS - EXPERIMENT -> Value.EXPERIMENT - DATASET -> Value.DATASET - else -> Value._UNKNOWN - } + fun value(): Value = when (this) { + PROJECTS -> Value.PROJECTS + LOGS -> Value.LOGS + EXPERIMENTS -> Value.EXPERIMENTS + DATASETS -> Value.DATASETS + PROMPTS -> Value.PROMPTS + PLAYGROUNDS -> Value.PLAYGROUNDS + EXPERIMENT -> Value.EXPERIMENT + DATASET -> Value.DATASET + else -> Value._UNKNOWN + } - fun known(): Known = - when (this) { - PROJECTS -> Known.PROJECTS - LOGS -> Known.LOGS - EXPERIMENTS -> Known.EXPERIMENTS - DATASETS -> Known.DATASETS - PROMPTS -> Known.PROMPTS - PLAYGROUNDS -> Known.PLAYGROUNDS - EXPERIMENT -> Known.EXPERIMENT - DATASET -> Known.DATASET - else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") - } + fun known(): Known = when (this) { + PROJECTS -> Known.PROJECTS + LOGS -> Known.LOGS + EXPERIMENTS -> Known.EXPERIMENTS + DATASETS -> Known.DATASETS + PROMPTS -> Known.PROMPTS + PLAYGROUNDS -> Known.PLAYGROUNDS + EXPERIMENT -> Known.EXPERIMENT + DATASET -> Known.DATASET + else -> throw BraintrustInvalidDataException("Unknown ViewType: $value") + } fun asString(): String = _value().asStringOrThrow() } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt index baa64dff..cf222b5d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/Handlers.kt @@ -2,25 +2,26 @@ package com.braintrustdata.api.services +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.google.common.collect.ListMultimap import com.braintrustdata.api.core.http.BinaryResponseContent import com.braintrustdata.api.core.http.HttpResponse import com.braintrustdata.api.core.http.HttpResponse.Handler import com.braintrustdata.api.errors.BadRequestException -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.errors.BraintrustException import com.braintrustdata.api.errors.InternalServerException import com.braintrustdata.api.errors.NotFoundException import com.braintrustdata.api.errors.PermissionDeniedException import com.braintrustdata.api.errors.RateLimitException +import com.braintrustdata.api.errors.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 com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.google.common.collect.ListMultimap import java.io.ByteArrayInputStream import java.io.InputStream import java.io.OutputStream +import java.util.Optional internal fun emptyHandler(): Handler = EmptyHandler @@ -41,8 +42,7 @@ private object StringHandler : Handler { private object BinaryHandler : Handler { override fun handle(response: HttpResponse): BinaryResponseContent { return object : BinaryResponseContent { - override fun contentType(): String? = - response.headers().get("Content-Type").firstOrNull() + override fun contentType(): String? = response.headers().get("Content-Type").firstOrNull() override fun body(): InputStream = response.body() @@ -159,6 +159,7 @@ internal fun Handler.withErrorHandler(errorHandler: Handler json( jsonMapper: JsonMapper, @@ -48,10 +48,7 @@ internal inline fun json( } } -internal fun multipartFormData( - jsonMapper: JsonMapper, - parts: Array?> -): HttpRequestBody { +internal fun multipartFormData(jsonMapper: JsonMapper, parts: Array?>): HttpRequestBody { val builder = MultipartEntityBuilder.create() parts.forEach { part -> if (part?.value != null) { @@ -63,30 +60,16 @@ internal fun multipartFormData( } catch (e: Exception) { throw BraintrustException("Error serializing value to json", e) } - builder.addBinaryBody( - part.name, - buffer.toByteArray(), - part.contentType, - part.filename - ) + builder.addBinaryBody(part.name, buffer.toByteArray(), part.contentType, part.filename) } - is Boolean -> - builder.addTextBody( - part.name, - if (part.value) "true" else "false", - part.contentType - ) + is Boolean -> builder.addTextBody (part.name, if (part.value) "true" else "false", part.contentType) is Int -> builder.addTextBody(part.name, part.value.toString(), part.contentType) is Long -> builder.addTextBody(part.name, part.value.toString(), part.contentType) is Double -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is ByteArray -> - builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) + is ByteArray -> builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) is String -> builder.addTextBody(part.name, part.value, part.contentType) is Enum -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - else -> - throw IllegalArgumentException( - "Unsupported content type: ${part.value::class.java.simpleName}" - ) + else -> throw IllegalArgumentException("Unsupported content type: ${part.value::class.java.simpleName}") } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt index 07ce4314..31081285 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsync.kt @@ -4,43 +4,63 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclListPageAsync import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface AclServiceAsync { /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in - * the request, will return the existing acl unmodified + * 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 */ - suspend fun create( - params: AclCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Acl + suspend fun create(params: AclCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Acl /** Get an acl object by its id */ - suspend fun retrieve( - params: AclRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Acl + suspend 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 */ - suspend fun list( - params: AclListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): AclListPageAsync + suspend fun list(params: AclListParams, requestOptions: RequestOptions = RequestOptions.none()): AclListPageAsync /** Delete an acl object by its id */ - suspend fun delete( - params: AclDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Acl + suspend fun delete(params: AclDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Acl } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt index e324b765..899a85b0 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/AclServiceAsyncImpl.kt @@ -2,140 +2,170 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclListPageAsync import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class AclServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : AclServiceAsync { +class AclServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : AclServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in - * the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one + * specified in the request, will return the existing acl unmodified */ override suspend fun create(params: AclCreateParams, requestOptions: RequestOptions): Acl { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get an acl object by its id */ override suspend fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): Acl { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun list( - params: AclListParams, - requestOptions: RequestOptions - ): AclListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { AclListPageAsync.of(this, params, it) } - } + override suspend fun list(params: AclListParams, requestOptions: RequestOptions): AclListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + AclListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete an acl object by its id */ override suspend fun delete(params: AclDeleteParams, requestOptions: RequestOptions): Acl { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsync.kt index b0b85d6a..4e362329 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyResourceCreateParams import com.braintrustdata.api.models.ApiKeyResourceDeleteParams @@ -12,36 +27,41 @@ import com.braintrustdata.api.models.ApiKeyResourceListPageAsync import com.braintrustdata.api.models.ApiKeyResourceListParams import com.braintrustdata.api.models.ApiKeyResourceRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface ApiKeyResourceServiceAsync { /** - * 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 */ - suspend fun create( - params: ApiKeyResourceCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CreateApiKeyOutput + suspend fun create(params: ApiKeyResourceCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CreateApiKeyOutput /** Get an api_key object by its id */ - suspend fun retrieve( - params: ApiKeyResourceRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ApiKey + suspend fun retrieve(params: ApiKeyResourceRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey /** * List out all api_keys. The api_keys are sorted by creation date, with the most * recently-created api_keys coming first */ - suspend fun list( - params: ApiKeyResourceListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ApiKeyResourceListPageAsync + suspend fun list(params: ApiKeyResourceListParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKeyResourceListPageAsync /** Delete an api_key object by its id */ - suspend fun delete( - params: ApiKeyResourceDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ApiKey + suspend fun delete(params: ApiKeyResourceDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsyncImpl.kt index dc74851a..be27b79d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyResourceServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyResourceCreateParams import com.braintrustdata.api.models.ApiKeyResourceDeleteParams @@ -15,137 +25,148 @@ import com.braintrustdata.api.models.ApiKeyResourceListPageAsync import com.braintrustdata.api.models.ApiKeyResourceListParams import com.braintrustdata.api.models.ApiKeyResourceRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ApiKeyResourceServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : ApiKeyResourceServiceAsync { +class ApiKeyResourceServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ApiKeyResourceServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun create( - params: ApiKeyResourceCreateParams, - requestOptions: RequestOptions - ): CreateApiKeyOutput { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun create(params: ApiKeyResourceCreateParams, requestOptions: RequestOptions): CreateApiKeyOutput { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get an api_key object by its id */ - override suspend fun retrieve( - params: ApiKeyResourceRetrieveParams, - requestOptions: RequestOptions - ): ApiKey { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: ApiKeyResourceRetrieveParams, requestOptions: RequestOptions): ApiKey { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all api_keys. The api_keys are sorted by creation date, with the most * recently-created api_keys coming first */ - override suspend fun list( - params: ApiKeyResourceListParams, - requestOptions: RequestOptions - ): ApiKeyResourceListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ApiKeyResourceListPageAsync.of(this, params, it) } - } + override suspend fun list(params: ApiKeyResourceListParams, requestOptions: RequestOptions): ApiKeyResourceListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ApiKeyResourceListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete an api_key object by its id */ - override suspend fun delete( - params: ApiKeyResourceDeleteParams, - requestOptions: RequestOptions - ): ApiKey { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override suspend fun delete(params: ApiKeyResourceDeleteParams, requestOptions: RequestOptions): ApiKey { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt deleted file mode 100755 index c2b31587..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsync.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.braintrustdata.api.services.async - -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.models.ApiKey -import com.braintrustdata.api.models.ApiKeyCreateParams -import com.braintrustdata.api.models.ApiKeyDeleteParams -import com.braintrustdata.api.models.ApiKeyListPageAsync -import com.braintrustdata.api.models.ApiKeyListParams -import com.braintrustdata.api.models.ApiKeyRetrieveParams -import com.braintrustdata.api.models.CreateApiKeyOutput - -interface ApiKeyServiceAsync { - - /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is - * no de-duplication - */ - suspend fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CreateApiKeyOutput - - /** Get an api_key object by its id */ - suspend 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 - * recently-created api_keys coming first - */ - suspend fun list( - params: ApiKeyListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ApiKeyListPageAsync - - /** Delete an api_key object by its id */ - suspend fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ApiKey -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt deleted file mode 100755 index a7d2dd58..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ApiKeyServiceAsyncImpl.kt +++ /dev/null @@ -1,151 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.async - -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.ApiKey -import com.braintrustdata.api.models.ApiKeyCreateParams -import com.braintrustdata.api.models.ApiKeyDeleteParams -import com.braintrustdata.api.models.ApiKeyListPageAsync -import com.braintrustdata.api.models.ApiKeyListParams -import com.braintrustdata.api.models.ApiKeyRetrieveParams -import com.braintrustdata.api.models.CreateApiKeyOutput -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler - -class ApiKeyServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : ApiKeyServiceAsync { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is - * no de-duplication - */ - override suspend fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions - ): CreateApiKeyOutput { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get an api_key object by its id */ - override suspend fun retrieve( - params: ApiKeyRetrieveParams, - requestOptions: RequestOptions - ): ApiKey { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all api_keys. The api_keys are sorted by creation date, with the most - * recently-created api_keys coming first - */ - override suspend fun list( - params: ApiKeyListParams, - requestOptions: RequestOptions - ): ApiKeyListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ApiKeyListPageAsync.of(this, params, it) } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an api_key object by its id */ - override suspend fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions - ): ApiKey { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt index d90700a3..2fd40323 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams import com.braintrustdata.api.models.DatasetDeleteParams @@ -21,82 +36,70 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface DatasetServiceAsync { /** - * Create a new dataset. If there is an existing dataset in the project with the same name as - * the one specified in the request, will return the existing dataset unmodified + * 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 */ - suspend fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Dataset + suspend fun create(params: DatasetCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** Get a dataset object by its id */ - suspend fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Dataset + suspend 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. */ - suspend fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Dataset + suspend fun update(params: DatasetUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** * List out all datasets. The datasets are sorted by creation date, with the most * recently-created datasets coming first */ - suspend fun list( - params: DatasetListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): DatasetListPageAsync + suspend fun list(params: DatasetListParams, requestOptions: RequestOptions = RequestOptions.none()): DatasetListPageAsync /** Delete a dataset object by its id */ - suspend fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Dataset + suspend fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Dataset /** Log feedback for a set of dataset events */ - suspend fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FeedbackResponseSchema + suspend 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 + * 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 */ - suspend fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FetchDatasetEventsResponse + suspend 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 + * 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 */ - suspend fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FetchDatasetEventsResponse + suspend fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchDatasetEventsResponse /** Insert a set of events into the dataset */ - suspend fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse + suspend fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse /** Summarize dataset */ - suspend fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none() - ): SummarizeDatasetResponse + suspend fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeDatasetResponse } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt index ab361d04..fd57ea29 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/DatasetServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams import com.braintrustdata.api.models.DatasetDeleteParams @@ -24,322 +34,325 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class DatasetServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : DatasetServiceAsync { +class DatasetServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : DatasetServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new dataset. If there is an existing dataset in the project with the same name as - * the one specified in the request, will return the existing dataset unmodified + * Create a new dataset. If there is an existing dataset in the project with the + * same name as the one specified in the request, will return the existing dataset + * unmodified */ - override suspend fun create( - params: DatasetCreateParams, - requestOptions: RequestOptions - ): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun create(params: DatasetCreateParams, requestOptions: RequestOptions): Dataset { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a dataset object by its id */ - override suspend fun retrieve( - params: DatasetRetrieveParams, - requestOptions: RequestOptions - ): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): Dataset { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a dataset object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - override suspend fun update( - params: DatasetUpdateParams, - requestOptions: RequestOptions - ): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): Dataset { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all datasets. The datasets are sorted by creation date, with the most * recently-created datasets coming first */ - override suspend fun list( - params: DatasetListParams, - requestOptions: RequestOptions - ): DatasetListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { DatasetListPageAsync.of(this, params, it) } - } + override suspend fun list(params: DatasetListParams, requestOptions: RequestOptions): DatasetListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + DatasetListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a dataset object by its id */ - override suspend fun delete( - params: DatasetDeleteParams, - requestOptions: RequestOptions - ): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override suspend fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): Dataset { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Log feedback for a set of dataset events */ - override suspend fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions - ): FeedbackResponseSchema { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + feedbackHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 + * 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 */ - override suspend fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions - ): FetchDatasetEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): FetchDatasetEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + fetchHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * 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 */ - override suspend fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions - ): FetchDatasetEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): FetchDatasetEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + fetchPostHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the dataset */ - override suspend fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): InsertEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + insertHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Summarize dataset */ - override suspend fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions - ): SummarizeDatasetResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { summarizeHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): SummarizeDatasetResponse { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + summarizeHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt index 61ee0ea0..57f057a4 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams import com.braintrustdata.api.models.ExperimentDeleteParams @@ -21,82 +36,70 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface ExperimentServiceAsync { /** - * Create a new experiment. If there is an existing experiment in the project with the same name - * as the one specified in the request, will return the existing experiment unmodified + * 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 */ - suspend fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Experiment + suspend fun create(params: ExperimentCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment /** Get an experiment object by its id */ - suspend fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Experiment + suspend 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. */ - suspend fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Experiment + suspend 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 */ - suspend fun list( - params: ExperimentListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ExperimentListPageAsync + suspend fun list(params: ExperimentListParams, requestOptions: RequestOptions = RequestOptions.none()): ExperimentListPageAsync /** Delete an experiment object by its id */ - suspend fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Experiment + suspend fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Experiment /** Log feedback for a set of experiment events */ - suspend fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FeedbackResponseSchema + suspend 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 + * 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 */ - suspend fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FetchExperimentEventsResponse + suspend 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 + * 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 */ - suspend fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FetchExperimentEventsResponse + suspend fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchExperimentEventsResponse /** Insert a set of events into the experiment */ - suspend fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse + suspend fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse /** Summarize experiment */ - suspend fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none() - ): SummarizeExperimentResponse + suspend fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeExperimentResponse } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt index 6d06c1fb..5dcf5ccd 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ExperimentServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams import com.braintrustdata.api.models.ExperimentDeleteParams @@ -24,322 +34,325 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ExperimentServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : ExperimentServiceAsync { +class ExperimentServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ExperimentServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): Experiment { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get an experiment object by its id */ - override suspend fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): Experiment { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update an experiment object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - override suspend fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): Experiment { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun list( - params: ExperimentListParams, - requestOptions: RequestOptions - ): ExperimentListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ExperimentListPageAsync.of(this, params, it) } - } + override suspend fun list(params: ExperimentListParams, requestOptions: RequestOptions): ExperimentListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ExperimentListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete an experiment object by its id */ - override suspend fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override suspend fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): Experiment { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Log feedback for a set of experiment events */ - override suspend fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions - ): FeedbackResponseSchema { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + feedbackHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 + * 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 */ - override suspend fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions - ): FetchExperimentEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): FetchExperimentEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + fetchHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * 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 */ - override suspend fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions - ): FetchExperimentEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): FetchExperimentEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + fetchPostHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ - override suspend fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): InsertEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + insertHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Summarize experiment */ - override suspend fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions - ): SummarizeExperimentResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { summarizeHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): SummarizeExperimentResponse { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + summarizeHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt index 78e66d95..be6c6db6 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams @@ -13,56 +28,56 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface FunctionServiceAsync { /** - * Create a new function. If there is an existing function in the project with the same slug as - * the one specified in the request, will return the existing function unmodified + * 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 */ - suspend fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Function + suspend fun create(params: FunctionCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** Get a function object by its id */ - suspend fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Function + suspend 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. */ - suspend fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Function + suspend fun update(params: FunctionUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** * List out all functions. The functions are sorted by creation date, with the most * recently-created functions coming first */ - suspend fun list( - params: FunctionListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FunctionListPageAsync + suspend fun list(params: FunctionListParams, requestOptions: RequestOptions = RequestOptions.none()): FunctionListPageAsync /** Delete a function object by its id */ - suspend fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Function + suspend fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** - * 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 */ - suspend fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Function + suspend fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Function } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt index 3fda06ad..a9484805 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/FunctionServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams @@ -16,203 +26,213 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class FunctionServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : FunctionServiceAsync { +class FunctionServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : FunctionServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new function. If there is an existing function in the project with the same slug as - * the one specified in the request, will return the existing function unmodified + * Create a new function. If there is an existing function in the project with the + * same slug as the one specified in the request, will return the existing function + * unmodified */ - override suspend fun create( - params: FunctionCreateParams, - requestOptions: RequestOptions - ): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun create(params: FunctionCreateParams, requestOptions: RequestOptions): Function { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a function object by its id */ - override suspend fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions - ): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): Function { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a function object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - override suspend fun update( - params: FunctionUpdateParams, - requestOptions: RequestOptions - ): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): Function { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all functions. The functions are sorted by creation date, with the most * recently-created functions coming first */ - override suspend fun list( - params: FunctionListParams, - requestOptions: RequestOptions - ): FunctionListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { FunctionListPageAsync.of(this, params, it) } - } + override suspend fun list(params: FunctionListParams, requestOptions: RequestOptions): FunctionListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + FunctionListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a function object by its id */ - override suspend fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions - ): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override suspend fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): Function { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace function. If there is an existing function in the project with the same - * slug as the one specified in the request, will replace the existing function with the - * provided fields + * Create or replace function. If there is an existing function in the project with + * the same slug as the one specified in the request, will replace the existing + * function with the provided fields */ - override suspend fun replace( - params: FunctionReplaceParams, - requestOptions: RequestOptions - ): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): Function { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt index d9fff275..5842c5dc 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams @@ -13,55 +28,55 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface GroupServiceAsync { /** - * Create a new group. If there is an existing group with the same name as the one specified in - * the request, will return the existing group unmodified + * 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 */ - suspend fun create( - params: GroupCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Group + suspend fun create(params: GroupCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Group /** Get a group object by its id */ - suspend fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Group + suspend 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. */ - suspend fun update( - params: GroupUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Group + suspend 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 */ - suspend fun list( - params: GroupListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): GroupListPageAsync + suspend fun list(params: GroupListParams, requestOptions: RequestOptions = RequestOptions.none()): GroupListPageAsync /** Delete a group object by its id */ - suspend fun delete( - params: GroupDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Group + suspend 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 */ - suspend fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Group + suspend fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Group } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt index 2e0e7ab6..128dbd76 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/GroupServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams @@ -16,193 +26,212 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class GroupServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : GroupServiceAsync { +class GroupServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : GroupServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new group. If there is an existing group with the same name as the one specified in - * the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one + * specified in the request, will return the existing group unmodified */ override suspend fun create(params: GroupCreateParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a group object by its id */ - override suspend fun retrieve( - params: GroupRetrieveParams, - requestOptions: RequestOptions - ): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): Group { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a group object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ override suspend fun update(params: GroupUpdateParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun list( - params: GroupListParams, - requestOptions: RequestOptions - ): GroupListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { GroupListPageAsync.of(this, params, it) } - } + override suspend fun list(params: GroupListParams, requestOptions: RequestOptions): GroupListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + GroupListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a group object by its id */ override suspend fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace group. If there is an existing group with the same name as the one - * specified in the request, will replace the existing group with the provided fields + * Create or replace group. If there is an existing group with the same name as the + * one specified in the request, will replace the existing group with the provided + * fields */ - override suspend fun replace( - params: GroupReplaceParams, - requestOptions: RequestOptions - ): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): Group { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrgSecretServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrgSecretServiceAsync.kt index 5c99514a..8bc40d80 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrgSecretServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrgSecretServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.OrgSecret import com.braintrustdata.api.models.OrgSecretCreateParams import com.braintrustdata.api.models.OrgSecretDeleteParams @@ -13,55 +28,56 @@ import com.braintrustdata.api.models.OrgSecretListParams import com.braintrustdata.api.models.OrgSecretReplaceParams import com.braintrustdata.api.models.OrgSecretRetrieveParams import com.braintrustdata.api.models.OrgSecretUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface OrgSecretServiceAsync { /** - * Create a new org_secret. If there is an existing org_secret with the same name as the one - * specified in the request, will return the existing org_secret unmodified + * Create a new org_secret. If there is an existing org_secret with the same name + * as the one specified in the request, will return the existing org_secret + * unmodified */ - suspend fun create( - params: OrgSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecret + suspend fun create(params: OrgSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecret /** Get an org_secret object by its id */ - suspend fun retrieve( - params: OrgSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecret + suspend fun retrieve(params: OrgSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecret /** - * Partially update an org_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 org_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. */ - suspend fun update( - params: OrgSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecret + suspend fun update(params: OrgSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecret /** - * List out all org_secrets. The org_secrets are sorted by creation date, with the most - * recently-created org_secrets coming first + * List out all org_secrets. The org_secrets are sorted by creation date, with the + * most recently-created org_secrets coming first */ - suspend fun list( - params: OrgSecretListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecretListPageAsync + suspend fun list(params: OrgSecretListParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecretListPageAsync /** Delete an org_secret object by its id */ - suspend fun delete( - params: OrgSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecret + suspend fun delete(params: OrgSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecret /** - * Create or replace org_secret. If there is an existing org_secret with the same name as the - * one specified in the request, will replace the existing org_secret with the provided fields + * Create or replace org_secret. If there is an existing org_secret with the same + * name as the one specified in the request, will replace the existing org_secret + * with the provided fields */ - suspend fun replace( - params: OrgSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecret + suspend fun replace(params: OrgSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecret } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrgSecretServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrgSecretServiceAsyncImpl.kt index 4e68a83b..4143a933 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrgSecretServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrgSecretServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.OrgSecret import com.braintrustdata.api.models.OrgSecretCreateParams import com.braintrustdata.api.models.OrgSecretDeleteParams @@ -16,202 +26,213 @@ import com.braintrustdata.api.models.OrgSecretListParams import com.braintrustdata.api.models.OrgSecretReplaceParams import com.braintrustdata.api.models.OrgSecretRetrieveParams import com.braintrustdata.api.models.OrgSecretUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class OrgSecretServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : OrgSecretServiceAsync { +class OrgSecretServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : OrgSecretServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new org_secret. If there is an existing org_secret with the same name as the one - * specified in the request, will return the existing org_secret unmodified + * Create a new org_secret. If there is an existing org_secret with the same name + * as the one specified in the request, will return the existing org_secret + * unmodified */ - override suspend fun create( - params: OrgSecretCreateParams, - requestOptions: RequestOptions - ): OrgSecret { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "org_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun create(params: OrgSecretCreateParams, requestOptions: RequestOptions): OrgSecret { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "org_secret") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get an org_secret object by its id */ - override suspend fun retrieve( - params: OrgSecretRetrieveParams, - requestOptions: RequestOptions - ): OrgSecret { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "org_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: OrgSecretRetrieveParams, requestOptions: RequestOptions): OrgSecret { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "org_secret", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update an org_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 org_secret object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - override suspend fun update( - params: OrgSecretUpdateParams, - requestOptions: RequestOptions - ): OrgSecret { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "org_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun update(params: OrgSecretUpdateParams, requestOptions: RequestOptions): OrgSecret { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "org_secret", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all org_secrets. The org_secrets are sorted by creation date, with the most - * recently-created org_secrets coming first + * List out all org_secrets. The org_secrets are sorted by creation date, with the + * most recently-created org_secrets coming first */ - override suspend fun list( - params: OrgSecretListParams, - requestOptions: RequestOptions - ): OrgSecretListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "org_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { OrgSecretListPageAsync.of(this, params, it) } - } + override suspend fun list(params: OrgSecretListParams, requestOptions: RequestOptions): OrgSecretListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "org_secret") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + OrgSecretListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete an org_secret object by its id */ - override suspend fun delete( - params: OrgSecretDeleteParams, - requestOptions: RequestOptions - ): OrgSecret { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "org_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override suspend fun delete(params: OrgSecretDeleteParams, requestOptions: RequestOptions): OrgSecret { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "org_secret", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace org_secret. If there is an existing org_secret with the same name as the - * one specified in the request, will replace the existing org_secret with the provided fields + * Create or replace org_secret. If there is an existing org_secret with the same + * name as the one specified in the request, will replace the existing org_secret + * with the provided fields */ - override suspend fun replace( - params: OrgSecretReplaceParams, - requestOptions: RequestOptions - ): OrgSecret { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "org_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun replace(params: OrgSecretReplaceParams, requestOptions: RequestOptions): OrgSecret { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "org_secret") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt index ba8a7707..667d1405 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsync.kt @@ -4,47 +4,68 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListPageAsync import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler import com.braintrustdata.api.services.async.organization.MemberServiceAsync +import com.braintrustdata.api.services.async.organization.MemberServiceAsyncImpl interface OrganizationServiceAsync { fun members(): MemberServiceAsync /** Get an organization object by its id */ - suspend fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Organization + suspend 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. */ - suspend fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Organization + suspend 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 */ - suspend fun list( - params: OrganizationListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrganizationListPageAsync + suspend fun list(params: OrganizationListParams, requestOptions: RequestOptions = RequestOptions.none()): OrganizationListPageAsync /** Delete an organization object by its id */ - suspend fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Organization + suspend fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Organization } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt index 44d34228..968e4f6d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/OrganizationServiceAsyncImpl.kt @@ -2,29 +2,49 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListPageAsync import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams -import com.braintrustdata.api.services.async.organization.MemberServiceAsync -import com.braintrustdata.api.services.async.organization.MemberServiceAsyncImpl +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import com.braintrustdata.api.services.async.organization.MemberServiceAsync +import com.braintrustdata.api.services.async.organization.MemberServiceAsyncImpl -class OrganizationServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : OrganizationServiceAsync { +class OrganizationServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : OrganizationServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -33,125 +53,126 @@ constructor( override fun members(): MemberServiceAsync = members private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get an organization object by its id */ - override suspend fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions - ): Organization { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): Organization { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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. */ - override suspend fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions - ): Organization { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): Organization { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun list( - params: OrganizationListParams, - requestOptions: RequestOptions - ): OrganizationListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { OrganizationListPageAsync.of(this, params, it) } - } + override suspend fun list(params: OrganizationListParams, requestOptions: RequestOptions): OrganizationListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + OrganizationListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete an organization object by its id */ - override suspend fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions - ): Organization { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override suspend fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): Organization { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt index 34d1e8e3..a4f81262 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams @@ -13,57 +28,56 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface ProjectScoreServiceAsync { /** - * 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 */ - suspend fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectScore + suspend fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore /** Get a project_score object by its id */ - suspend fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectScore + suspend 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. */ - suspend fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectScore + suspend 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 */ - suspend fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectScoreListPageAsync + suspend fun list(params: ProjectScoreListParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScoreListPageAsync /** Delete a project_score object by its id */ - suspend fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectScore + suspend 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 */ - suspend fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectScore + suspend fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt index 699cf6bd..b3b7f2db 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectScoreServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams @@ -16,204 +26,213 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ProjectScoreServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : ProjectScoreServiceAsync { +class ProjectScoreServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ProjectScoreServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): ProjectScore { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a project_score object by its id */ - override suspend fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): ProjectScore { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a project_score object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - override suspend fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): ProjectScore { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ - override suspend fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions - ): ProjectScoreListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ProjectScoreListPageAsync.of(this, params, it) } - } + override suspend fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): ProjectScoreListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ProjectScoreListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a project_score object by its id */ - override suspend fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override suspend fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): ProjectScore { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): ProjectScore { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt index dc14a692..1eb4441e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams @@ -12,49 +27,52 @@ import com.braintrustdata.api.models.ProjectListPageAsync import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler import com.braintrustdata.api.services.async.project.LogServiceAsync +import com.braintrustdata.api.services.async.project.LogServiceAsyncImpl interface ProjectServiceAsync { 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 */ - suspend fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Project + suspend fun create(params: ProjectCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Project /** Get a project object by its id */ - suspend fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Project + suspend 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. */ - suspend fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Project + suspend fun update(params: ProjectUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): Project /** * List out all projects. The projects are sorted by creation date, with the most * recently-created projects coming first */ - suspend fun list( - params: ProjectListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectListPageAsync + suspend fun list(params: ProjectListParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectListPageAsync /** Delete a project object by its id */ - suspend fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Project + suspend fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Project } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt index 1576c774..b5287a5d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams @@ -15,17 +25,27 @@ import com.braintrustdata.api.models.ProjectListPageAsync import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.services.async.project.LogServiceAsync -import com.braintrustdata.api.services.async.project.LogServiceAsyncImpl +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import com.braintrustdata.api.services.async.project.LogServiceAsync +import com.braintrustdata.api.services.async.project.LogServiceAsyncImpl -class ProjectServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : ProjectServiceAsync { +class ProjectServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ProjectServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -34,157 +54,157 @@ constructor( override fun logs(): LogServiceAsync = logs private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new project. If there is an existing project with the same name as the one specified - * in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the + * one specified in the request, will return the existing project unmodified */ - override suspend fun create( - params: ProjectCreateParams, - requestOptions: RequestOptions - ): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun create(params: ProjectCreateParams, requestOptions: RequestOptions): Project { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a project object by its id */ - override suspend fun retrieve( - params: ProjectRetrieveParams, - requestOptions: RequestOptions - ): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): Project { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a project object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - override suspend fun update( - params: ProjectUpdateParams, - requestOptions: RequestOptions - ): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): Project { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all projects. The projects are sorted by creation date, with the most * recently-created projects coming first */ - override suspend fun list( - params: ProjectListParams, - requestOptions: RequestOptions - ): ProjectListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ProjectListPageAsync.of(this, params, it) } - } + override suspend fun list(params: ProjectListParams, requestOptions: RequestOptions): ProjectListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ProjectListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a project object by its id */ - override suspend fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions - ): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override suspend fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): Project { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt index 85c4f073..3cb1a8af 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams @@ -13,56 +28,56 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface ProjectTagServiceAsync { /** - * Create a new project_tag. If there is an existing project_tag in the project with the same - * name as the one specified in the request, will return the existing project_tag unmodified + * 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 */ - suspend fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectTag + suspend fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag /** Get a project_tag object by its id */ - suspend fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectTag + suspend 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. */ - suspend fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectTag + suspend 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 */ - suspend fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectTagListPageAsync + suspend fun list(params: ProjectTagListParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTagListPageAsync /** Delete a project_tag object by its id */ - suspend fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectTag + suspend 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 */ - suspend fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectTag + suspend fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt index 617eb650..3d54f172 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ProjectTagServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams @@ -16,203 +26,213 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ProjectTagServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : ProjectTagServiceAsync { +class ProjectTagServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ProjectTagServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): ProjectTag { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a project_tag object by its id */ - override suspend fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): ProjectTag { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a project_tag object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - override suspend fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): ProjectTag { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ - override suspend fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions - ): ProjectTagListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ProjectTagListPageAsync.of(this, params, it) } - } + override suspend fun list(params: ProjectTagListParams, requestOptions: RequestOptions): ProjectTagListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ProjectTagListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a project_tag object by its id */ - override suspend fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override suspend fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): ProjectTag { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): ProjectTag { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt index 94342356..8b65b193 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams @@ -13,55 +28,56 @@ import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface PromptServiceAsync { /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will return the existing prompt unmodified + * 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 */ - suspend fun create( - params: PromptCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Prompt + suspend fun create(params: PromptCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt /** Get a prompt object by its id */ - suspend fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Prompt + suspend 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. */ - suspend fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Prompt + suspend 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 */ - suspend fun list( - params: PromptListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): PromptListPageAsync + suspend fun list(params: PromptListParams, requestOptions: RequestOptions = RequestOptions.none()): PromptListPageAsync /** Delete a prompt object by its id */ - suspend fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Prompt + suspend 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 */ - suspend fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Prompt + suspend fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt index c77cd3e3..11942b18 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/PromptServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams @@ -16,202 +26,213 @@ import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class PromptServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : PromptServiceAsync { +class PromptServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : PromptServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will return the existing prompt unmodified + * Create a new prompt. If there is an existing prompt in the project with the same + * slug as the one specified in the request, will return the existing prompt + * unmodified */ - override suspend fun create( - params: PromptCreateParams, - requestOptions: RequestOptions - ): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun create(params: PromptCreateParams, requestOptions: RequestOptions): Prompt { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a prompt object by its id */ - override suspend fun retrieve( - params: PromptRetrieveParams, - requestOptions: RequestOptions - ): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): Prompt { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a prompt object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ - override suspend fun update( - params: PromptUpdateParams, - requestOptions: RequestOptions - ): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun update(params: PromptUpdateParams, requestOptions: RequestOptions): Prompt { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun list( - params: PromptListParams, - requestOptions: RequestOptions - ): PromptListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { PromptListPageAsync.of(this, params, it) } - } + override suspend fun list(params: PromptListParams, requestOptions: RequestOptions): PromptListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + PromptListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a prompt object by its id */ - override suspend fun delete( - params: PromptDeleteParams, - requestOptions: RequestOptions - ): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override suspend fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): Prompt { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace prompt. If there is an existing prompt in the project with the same slug as - * the one specified in the request, will replace the existing prompt with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the + * same slug as the one specified in the request, will replace the existing prompt + * with the provided fields */ - override suspend fun replace( - params: PromptReplaceParams, - requestOptions: RequestOptions - ): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): Prompt { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt index e5f7849c..07338e46 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams @@ -13,55 +28,55 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface RoleServiceAsync { /** - * Create a new role. If there is an existing role with the same name as the one specified in - * the request, will return the existing role unmodified + * 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 */ - suspend fun create( - params: RoleCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Role + suspend fun create(params: RoleCreateParams, requestOptions: RequestOptions = RequestOptions.none()): Role /** Get a role object by its id */ - suspend fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Role + suspend 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. */ - suspend fun update( - params: RoleUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Role + suspend 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 */ - suspend fun list( - params: RoleListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): RoleListPageAsync + suspend fun list(params: RoleListParams, requestOptions: RequestOptions = RequestOptions.none()): RoleListPageAsync /** Delete a role object by its id */ - suspend fun delete( - params: RoleDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Role + suspend 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 */ - suspend fun replace( - params: RoleReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Role + suspend fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Role } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt index 321be90e..0e510d3e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/RoleServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams @@ -16,190 +26,212 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class RoleServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : RoleServiceAsync { +class RoleServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : RoleServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new role. If there is an existing role with the same name as the one specified in - * the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one + * specified in the request, will return the existing role unmodified */ override suspend fun create(params: RoleCreateParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a role object by its id */ - override suspend fun retrieve( - params: RoleRetrieveParams, - requestOptions: RequestOptions - ): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): Role { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a role object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ override suspend fun update(params: RoleUpdateParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun list( - params: RoleListParams, - requestOptions: RequestOptions - ): RoleListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { RoleListPageAsync.of(this, params, it) } - } + override suspend fun list(params: RoleListParams, requestOptions: RequestOptions): RoleListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + RoleListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a role object by its id */ override suspend fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace role. If there is an existing role with the same name as the one specified - * in the request, will replace the existing role with the provided fields + * Create or replace role. If there is an existing role with the same name as the + * one specified in the request, will replace the existing role with the provided + * fields */ override suspend fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt index 3df67acd..2b5579c5 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsync.kt @@ -4,14 +4,46 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.TopLevelHelloWorldParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface TopLevelServiceAsync { - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ - suspend fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions = RequestOptions.none() - ): String + /** + * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not + * required + */ + suspend fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions = RequestOptions.none()): String } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt index a6da8c44..fea89b42 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/TopLevelServiceAsyncImpl.kt @@ -2,42 +2,67 @@ package com.braintrustdata.api.services.async +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.TopLevelHelloWorldParams import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.TopLevelHelloWorldParams +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class TopLevelServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : TopLevelServiceAsync { +class TopLevelServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : TopLevelServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) + private val helloWorldHandler: Handler = + stringHandler() + .withErrorHandler(errorHandler) - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ - override suspend fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions - ): String { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response.use { helloWorldHandler.handle(it) } - } + /** + * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not + * required + */ + override suspend fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): String { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + helloWorldHandler.handle(it) + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt index 9da26437..42f07342 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsync.kt @@ -4,26 +4,52 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.User import com.braintrustdata.api.models.UserListPageAsync import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface UserServiceAsync { /** Get a user object by its id */ - suspend fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): User + suspend 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 */ - suspend fun list( - params: UserListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): UserListPageAsync + suspend fun list(params: UserListParams, requestOptions: RequestOptions = RequestOptions.none()): UserListPageAsync } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt index 0c4276d2..7ef98977 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/UserServiceAsyncImpl.kt @@ -2,85 +2,105 @@ package com.braintrustdata.api.services.async +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.User +import com.braintrustdata.api.models.UserListPageAsync +import com.braintrustdata.api.models.UserListParams +import com.braintrustdata.api.models.UserRetrieveParams import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.User -import com.braintrustdata.api.models.UserListPageAsync -import com.braintrustdata.api.models.UserListParams -import com.braintrustdata.api.models.UserRetrieveParams +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class UserServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : UserServiceAsync { +class UserServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : UserServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a user object by its id */ - override suspend fun retrieve( - params: UserRetrieveParams, - requestOptions: RequestOptions - ): User { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): User { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun list( - params: UserListParams, - requestOptions: RequestOptions - ): UserListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { UserListPageAsync.of(this, params, it) } - } + override suspend fun list(params: UserListParams, requestOptions: RequestOptions): UserListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + UserListPageAsync.of(this, params, it) + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt index dd1491b4..37b683b1 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams @@ -13,55 +28,55 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface ViewServiceAsync { /** - * Create a new view. If there is an existing view with the same name as the one specified in - * the request, will return the existing view unmodified + * 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 */ - suspend fun create( - params: ViewCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): View + suspend fun create(params: ViewCreateParams, requestOptions: RequestOptions = RequestOptions.none()): View /** Get a view object by its id */ - suspend fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): View + suspend 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. */ - suspend fun update( - params: ViewUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): View + suspend 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 */ - suspend fun list( - params: ViewListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ViewListPageAsync + suspend fun list(params: ViewListParams, requestOptions: RequestOptions = RequestOptions.none()): ViewListPageAsync /** Delete a view object by its id */ - suspend fun delete( - params: ViewDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): View + suspend 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 */ - suspend fun replace( - params: ViewReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() - ): View + suspend fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): View } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt index c39c4bd4..23aab375 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/ViewServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams @@ -16,190 +26,208 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ViewServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : ViewServiceAsync { +class ViewServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : ViewServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new view. If there is an existing view with the same name as the one specified in - * the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one + * specified in the request, will return the existing view unmodified */ override suspend fun create(params: ViewCreateParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a view object by its id */ - override suspend fun retrieve( - params: ViewRetrieveParams, - requestOptions: RequestOptions - ): View { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): View { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a view object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ override suspend fun update(params: ViewUpdateParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override suspend fun list( - params: ViewListParams, - requestOptions: RequestOptions - ): ViewListPageAsync { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ViewListPageAsync.of(this, params, it) } - } + override suspend fun list(params: ViewListParams, requestOptions: RequestOptions): ViewListPageAsync { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ViewListPageAsync.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a view object by its id */ override suspend fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace view. If there is an existing view with the same name as the one specified - * in the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the + * one specified in the request, will replace the existing view with the provided + * fields */ override suspend fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsync.kt index 63aeac82..655dab85 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsync.kt @@ -4,15 +4,44 @@ package com.braintrustdata.api.services.async.organization -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.OrganizationMemberUpdateResponse +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface MemberServiceAsync { /** Modify organization membership */ - suspend fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrganizationMemberUpdateResponse + suspend fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): OrganizationMemberUpdateResponse } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsyncImpl.kt index 17b10068..08be4462 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organization/MemberServiceAsyncImpl.kt @@ -2,53 +2,71 @@ package com.braintrustdata.api.services.async.organization +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.OrganizationMemberUpdateParams +import com.braintrustdata.api.models.OrganizationMemberUpdateResponse import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.OrganizationMemberUpdateParams -import com.braintrustdata.api.models.OrganizationMemberUpdateResponse +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class MemberServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : MemberServiceAsync { +class MemberServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : MemberServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Modify organization membership */ - override suspend fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions - ): OrganizationMemberUpdateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): OrganizationMemberUpdateResponse { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt deleted file mode 100755 index f2cb0e5d..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsync.kt +++ /dev/null @@ -1,18 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.braintrustdata.api.services.async.organizations - -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.models.OrganizationMemberUpdateParams -import com.braintrustdata.api.models.OrganizationMemberUpdateResponse - -interface MemberServiceAsync { - - /** Modify organization membership */ - suspend fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrganizationMemberUpdateResponse -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt deleted file mode 100755 index f0b3a26d..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/organizations/MemberServiceAsyncImpl.kt +++ /dev/null @@ -1,54 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.async.organizations - -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.OrganizationMemberUpdateParams -import com.braintrustdata.api.models.OrganizationMemberUpdateResponse -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler - -class MemberServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : MemberServiceAsync { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Modify organization membership */ - override suspend fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions - ): OrganizationMemberUpdateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsync.kt index 8d9698f7..ebceca30 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsync.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsync.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.async.project -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse import com.braintrustdata.api.models.InsertEventsResponse @@ -12,36 +27,41 @@ import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface LogServiceAsync { /** Log feedback for a set of project logs events */ - suspend fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FeedbackResponseSchema + suspend 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 + * 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 */ - suspend fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FetchProjectLogsEventsResponse + suspend 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 + * 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 */ - suspend fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FetchProjectLogsEventsResponse + suspend fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions = RequestOptions.none()): FetchProjectLogsEventsResponse /** Insert a set of events into the project logs */ - suspend fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse + suspend fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsyncImpl.kt index 1da96f77..f5f53ef6 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsyncImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/project/LogServiceAsyncImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.async.project -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse import com.braintrustdata.api.models.InsertEventsResponse @@ -15,138 +25,142 @@ import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class LogServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : LogServiceAsync { +class LogServiceAsyncImpl constructor(private val clientOptions: ClientOptions, ) : LogServiceAsync { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Log feedback for a set of project logs events */ - override suspend fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions - ): FeedbackResponseSchema { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + feedbackHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body + * 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 */ - override suspend fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions - ): FetchProjectLogsEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): FetchProjectLogsEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + fetchHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * 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 */ - override suspend fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions - ): FetchProjectLogsEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): FetchProjectLogsEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + fetchPostHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ - override suspend fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override suspend fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): InsertEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions) + .let { response -> + response.use { + insertHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt deleted file mode 100755 index 3cae5172..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsync.kt +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.braintrustdata.api.services.async.projects - -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse -import com.braintrustdata.api.models.ProjectLogFeedbackParams -import com.braintrustdata.api.models.ProjectLogFetchParams -import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogInsertParams - -interface LogServiceAsync { - - /** Log feedback for a set of project logs events */ - suspend fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() - ) - - /** - * 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 - */ - suspend 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 - */ - suspend fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FetchProjectLogsEventsResponse - - /** Insert a set of events into the project logs */ - suspend fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt deleted file mode 100755 index 98807822..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/async/projects/LogServiceAsyncImpl.kt +++ /dev/null @@ -1,145 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.async.projects - -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse -import com.braintrustdata.api.models.ProjectLogFeedbackParams -import com.braintrustdata.api.models.ProjectLogFetchParams -import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler - -class LogServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : LogServiceAsync { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val feedbackHandler: Handler = emptyHandler().withErrorHandler(errorHandler) - - /** Log feedback for a set of project logs events */ - override suspend fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions - ) { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response.use { feedbackHandler.handle(it) } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body - */ - override suspend fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions - ): FetchProjectLogsEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query - */ - override suspend fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions - ): FetchProjectLogsEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Insert a set of events into the project logs */ - override suspend fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt index 4bffc71d..c5e2ce6a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclService.kt @@ -4,36 +4,62 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface AclService { /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in - * the request, will return the existing acl unmodified + * 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, requestOptions: RequestOptions = RequestOptions.none()): Acl /** Get an acl object by its id */ - 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, - 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, requestOptions: RequestOptions = RequestOptions.none()): Acl diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt index aee5258a..f15d871e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/AclServiceImpl.kt @@ -2,136 +2,170 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Acl import com.braintrustdata.api.models.AclCreateParams import com.braintrustdata.api.models.AclDeleteParams import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams import com.braintrustdata.api.models.AclRetrieveParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class AclServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : AclService { +class AclServiceImpl constructor(private val clientOptions: ClientOptions, ) : AclService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new acl. If there is an existing acl with the same contents as the one specified in - * the request, will return the existing acl unmodified + * Create a new acl. If there is an existing acl with the same contents as the one + * specified in the request, will return the existing acl unmodified */ override fun create(params: AclCreateParams, requestOptions: RequestOptions): Acl { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "acl") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get an acl object by its id */ override fun retrieve(params: AclRetrieveParams, requestOptions: RequestOptions): Acl { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ override fun list(params: AclListParams, requestOptions: RequestOptions): AclListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "acl") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { AclListPage.of(this, params, it) } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "acl") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + AclListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete an acl object by its id */ override fun delete(params: AclDeleteParams, requestOptions: RequestOptions): Acl { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "acl", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "acl", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceService.kt index ded8ffa4..c9041c87 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyResourceCreateParams import com.braintrustdata.api.models.ApiKeyResourceDeleteParams @@ -12,36 +27,41 @@ import com.braintrustdata.api.models.ApiKeyResourceListPage import com.braintrustdata.api.models.ApiKeyResourceListParams import com.braintrustdata.api.models.ApiKeyResourceRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface ApiKeyResourceService { /** - * 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: ApiKeyResourceCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CreateApiKeyOutput + fun create(params: ApiKeyResourceCreateParams, requestOptions: RequestOptions = RequestOptions.none()): CreateApiKeyOutput /** Get an api_key object by its id */ - fun retrieve( - params: ApiKeyResourceRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ApiKey + fun retrieve(params: ApiKeyResourceRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey /** * List out all api_keys. The api_keys are sorted by creation date, with the most * recently-created api_keys coming first */ - fun list( - params: ApiKeyResourceListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ApiKeyResourceListPage + fun list(params: ApiKeyResourceListParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKeyResourceListPage /** Delete an api_key object by its id */ - fun delete( - params: ApiKeyResourceDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ApiKey + fun delete(params: ApiKeyResourceDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): ApiKey } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceImpl.kt index d1f7e769..95850a8a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ApiKey import com.braintrustdata.api.models.ApiKeyResourceCreateParams import com.braintrustdata.api.models.ApiKeyResourceDeleteParams @@ -15,137 +25,148 @@ import com.braintrustdata.api.models.ApiKeyResourceListPage import com.braintrustdata.api.models.ApiKeyResourceListParams import com.braintrustdata.api.models.ApiKeyResourceRetrieveParams import com.braintrustdata.api.models.CreateApiKeyOutput +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ApiKeyResourceServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : ApiKeyResourceService { +class ApiKeyResourceServiceImpl constructor(private val clientOptions: ClientOptions, ) : ApiKeyResourceService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override fun create( - params: ApiKeyResourceCreateParams, - requestOptions: RequestOptions - ): CreateApiKeyOutput { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create(params: ApiKeyResourceCreateParams, requestOptions: RequestOptions): CreateApiKeyOutput { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "api_key") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get an api_key object by its id */ - override fun retrieve( - params: ApiKeyResourceRetrieveParams, - requestOptions: RequestOptions - ): ApiKey { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve(params: ApiKeyResourceRetrieveParams, requestOptions: RequestOptions): ApiKey { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all api_keys. The api_keys are sorted by creation date, with the most * recently-created api_keys coming first */ - override fun list( - params: ApiKeyResourceListParams, - requestOptions: RequestOptions - ): ApiKeyResourceListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ApiKeyResourceListPage.of(this, params, it) } - } + override fun list(params: ApiKeyResourceListParams, requestOptions: RequestOptions): ApiKeyResourceListPage { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "api_key") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ApiKeyResourceListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete an api_key object by its id */ - override fun delete( - params: ApiKeyResourceDeleteParams, - requestOptions: RequestOptions - ): ApiKey { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override fun delete(params: ApiKeyResourceDeleteParams, requestOptions: RequestOptions): ApiKey { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "api_key", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt deleted file mode 100755 index 1dde7295..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyService.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.braintrustdata.api.services.blocking - -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.models.ApiKey -import com.braintrustdata.api.models.ApiKeyCreateParams -import com.braintrustdata.api.models.ApiKeyDeleteParams -import com.braintrustdata.api.models.ApiKeyListPage -import com.braintrustdata.api.models.ApiKeyListParams -import com.braintrustdata.api.models.ApiKeyRetrieveParams -import com.braintrustdata.api.models.CreateApiKeyOutput - -interface ApiKeyService { - - /** - * 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, - requestOptions: RequestOptions = RequestOptions.none() - ): CreateApiKeyOutput - - /** Get an api_key object by its id */ - 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 - * recently-created api_keys coming first - */ - fun list( - params: ApiKeyListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ApiKeyListPage - - /** Delete an api_key object by its id */ - fun delete( - params: ApiKeyDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ApiKey -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt deleted file mode 100755 index 199c4382..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceImpl.kt +++ /dev/null @@ -1,142 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.blocking - -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.ApiKey -import com.braintrustdata.api.models.ApiKeyCreateParams -import com.braintrustdata.api.models.ApiKeyDeleteParams -import com.braintrustdata.api.models.ApiKeyListPage -import com.braintrustdata.api.models.ApiKeyListParams -import com.braintrustdata.api.models.ApiKeyRetrieveParams -import com.braintrustdata.api.models.CreateApiKeyOutput -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler - -class ApiKeyServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : ApiKeyService { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Create a new api_key. It is possible to have multiple API keys with the same name. There is - * no de-duplication - */ - override fun create( - params: ApiKeyCreateParams, - requestOptions: RequestOptions - ): CreateApiKeyOutput { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Get an api_key object by its id */ - override fun retrieve(params: ApiKeyRetrieveParams, requestOptions: RequestOptions): ApiKey { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * List out all api_keys. The api_keys are sorted by creation date, with the most - * recently-created api_keys coming first - */ - override fun list(params: ApiKeyListParams, requestOptions: RequestOptions): ApiKeyListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "api_key") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ApiKeyListPage.of(this, params, it) } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Delete an api_key object by its id */ - override fun delete(params: ApiKeyDeleteParams, requestOptions: RequestOptions): ApiKey { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "api_key", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt index 5caf0e79..8e1264ee 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams import com.braintrustdata.api.models.DatasetDeleteParams @@ -21,82 +36,70 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface DatasetService { /** - * Create a new dataset. If there is an existing dataset in the project with the same name as - * the one specified in the request, will return the existing dataset unmodified + * 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, - 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, - 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, - 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 * recently-created datasets coming first */ - fun list( - params: DatasetListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): DatasetListPage + fun list(params: DatasetListParams, requestOptions: RequestOptions = RequestOptions.none()): DatasetListPage /** Delete a dataset object by its id */ - 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, - 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 + * 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 */ - 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 + * 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 */ - 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, - requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse + fun insert(params: DatasetInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse /** Summarize dataset */ - fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none() - ): SummarizeDatasetResponse + fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeDatasetResponse } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt index 8213b074..ff302c1c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Dataset import com.braintrustdata.api.models.DatasetCreateParams import com.braintrustdata.api.models.DatasetDeleteParams @@ -24,307 +34,325 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchDatasetEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeDatasetResponse +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class DatasetServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : DatasetService { +class DatasetServiceImpl constructor(private val clientOptions: ClientOptions, ) : DatasetService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new dataset. If there is an existing dataset in the project with the same name as - * the one specified in the request, will return the existing dataset unmodified + * Create a new dataset. If there is an existing dataset in the project with the + * same name as the one specified in the request, will return the existing dataset + * unmodified */ override fun create(params: DatasetCreateParams, requestOptions: RequestOptions): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a dataset object by its id */ override fun retrieve(params: DatasetRetrieveParams, requestOptions: RequestOptions): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a dataset object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a dataset object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ override fun update(params: DatasetUpdateParams, requestOptions: RequestOptions): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all datasets. The datasets are sorted by creation date, with the most * recently-created datasets coming first */ override fun list(params: DatasetListParams, requestOptions: RequestOptions): DatasetListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { DatasetListPage.of(this, params, it) } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + DatasetListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a dataset object by its id */ override fun delete(params: DatasetDeleteParams, requestOptions: RequestOptions): Dataset { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "dataset", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "dataset", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Log feedback for a set of dataset events */ - override fun feedback( - params: DatasetFeedbackParams, - requestOptions: RequestOptions - ): FeedbackResponseSchema { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun feedback(params: DatasetFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + feedbackHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 + * 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 */ - override fun fetch( - params: DatasetFetchParams, - requestOptions: RequestOptions - ): FetchDatasetEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetch(params: DatasetFetchParams, requestOptions: RequestOptions): FetchDatasetEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + fetchHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * 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 */ - override fun fetchPost( - params: DatasetFetchPostParams, - requestOptions: RequestOptions - ): FetchDatasetEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetchPost(params: DatasetFetchPostParams, requestOptions: RequestOptions): FetchDatasetEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + fetchPostHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the dataset */ - override fun insert( - params: DatasetInsertParams, - requestOptions: RequestOptions - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun insert(params: DatasetInsertParams, requestOptions: RequestOptions): InsertEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "dataset", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + insertHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Summarize dataset */ - override fun summarize( - params: DatasetSummarizeParams, - requestOptions: RequestOptions - ): SummarizeDatasetResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { summarizeHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun summarize(params: DatasetSummarizeParams, requestOptions: RequestOptions): SummarizeDatasetResponse { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "dataset", params.getPathParam(0), "summarize") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + summarizeHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt index ad57304b..cd49fe14 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams import com.braintrustdata.api.models.ExperimentDeleteParams @@ -21,82 +36,70 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface ExperimentService { /** - * Create a new experiment. If there is an existing experiment in the project with the same name - * as the one specified in the request, will return the existing experiment unmodified + * 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, - 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, - 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, - 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( - params: ExperimentListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ExperimentListPage + fun list(params: ExperimentListParams, requestOptions: RequestOptions = RequestOptions.none()): ExperimentListPage /** Delete an experiment object by its id */ - 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, - 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 + * 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 */ - 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 + * 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 */ - 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, - requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse + fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse /** Summarize experiment */ - fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions = RequestOptions.none() - ): SummarizeExperimentResponse + fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions = RequestOptions.none()): SummarizeExperimentResponse } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt index a150dcf2..4d65d361 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Experiment import com.braintrustdata.api.models.ExperimentCreateParams import com.braintrustdata.api.models.ExperimentDeleteParams @@ -24,322 +34,325 @@ import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchExperimentEventsResponse import com.braintrustdata.api.models.InsertEventsResponse import com.braintrustdata.api.models.SummarizeExperimentResponse +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ExperimentServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : ExperimentService { +class ExperimentServiceImpl constructor(private val clientOptions: ClientOptions, ) : ExperimentService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override fun create( - params: ExperimentCreateParams, - requestOptions: RequestOptions - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create(params: ExperimentCreateParams, requestOptions: RequestOptions): Experiment { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get an experiment object by its id */ - override fun retrieve( - params: ExperimentRetrieveParams, - requestOptions: RequestOptions - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve(params: ExperimentRetrieveParams, requestOptions: RequestOptions): Experiment { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update an experiment object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update an experiment object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - override fun update( - params: ExperimentUpdateParams, - requestOptions: RequestOptions - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update(params: ExperimentUpdateParams, requestOptions: RequestOptions): Experiment { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override fun list( - params: ExperimentListParams, - requestOptions: RequestOptions - ): ExperimentListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ExperimentListPage.of(this, params, it) } - } + override fun list(params: ExperimentListParams, requestOptions: RequestOptions): ExperimentListPage { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ExperimentListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete an experiment object by its id */ - override fun delete( - params: ExperimentDeleteParams, - requestOptions: RequestOptions - ): Experiment { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "experiment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override fun delete(params: ExperimentDeleteParams, requestOptions: RequestOptions): Experiment { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "experiment", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Log feedback for a set of experiment events */ - override fun feedback( - params: ExperimentFeedbackParams, - requestOptions: RequestOptions - ): FeedbackResponseSchema { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun feedback(params: ExperimentFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + feedbackHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 + * 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 */ - override fun fetch( - params: ExperimentFetchParams, - requestOptions: RequestOptions - ): FetchExperimentEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetch(params: ExperimentFetchParams, requestOptions: RequestOptions): FetchExperimentEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + fetchHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * 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 */ - override fun fetchPost( - params: ExperimentFetchPostParams, - requestOptions: RequestOptions - ): FetchExperimentEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetchPost(params: ExperimentFetchPostParams, requestOptions: RequestOptions): FetchExperimentEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + fetchPostHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the experiment */ - override fun insert( - params: ExperimentInsertParams, - requestOptions: RequestOptions - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun insert(params: ExperimentInsertParams, requestOptions: RequestOptions): InsertEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "experiment", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + insertHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val summarizeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Summarize experiment */ - override fun summarize( - params: ExperimentSummarizeParams, - requestOptions: RequestOptions - ): SummarizeExperimentResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { summarizeHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun summarize(params: ExperimentSummarizeParams, requestOptions: RequestOptions): SummarizeExperimentResponse { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "experiment", params.getPathParam(0), "summarize") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + summarizeHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt index 3ce0f7a9..f2cd0ae5 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams @@ -13,56 +28,56 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface FunctionService { /** - * Create a new function. If there is an existing function in the project with the same slug as - * the one specified in the request, will return the existing function unmodified + * 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, - 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, - 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, - 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 * recently-created functions coming first */ - fun list( - params: FunctionListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FunctionListPage + fun list(params: FunctionListParams, requestOptions: RequestOptions = RequestOptions.none()): FunctionListPage /** Delete a function object by its id */ - fun delete( - params: FunctionDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Function + fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Function /** - * 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, - requestOptions: RequestOptions = RequestOptions.none() - ): Function + fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Function } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt index 95410c08..fec257ae 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Function import com.braintrustdata.api.models.FunctionCreateParams import com.braintrustdata.api.models.FunctionDeleteParams @@ -16,191 +26,213 @@ import com.braintrustdata.api.models.FunctionListParams import com.braintrustdata.api.models.FunctionReplaceParams import com.braintrustdata.api.models.FunctionRetrieveParams import com.braintrustdata.api.models.FunctionUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class FunctionServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : FunctionService { +class FunctionServiceImpl constructor(private val clientOptions: ClientOptions, ) : FunctionService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new function. If there is an existing function in the project with the same slug as - * the one specified in the request, will return the existing function unmodified + * Create a new function. If there is an existing function in the project with the + * same slug as the one specified in the request, will return the existing function + * unmodified */ override fun create(params: FunctionCreateParams, requestOptions: RequestOptions): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a function object by its id */ - override fun retrieve( - params: FunctionRetrieveParams, - requestOptions: RequestOptions - ): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve(params: FunctionRetrieveParams, requestOptions: RequestOptions): Function { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a function object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a function object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ override fun update(params: FunctionUpdateParams, requestOptions: RequestOptions): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all functions. The functions are sorted by creation date, with the most * recently-created functions coming first */ - override fun list( - params: FunctionListParams, - requestOptions: RequestOptions - ): FunctionListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { FunctionListPage.of(this, params, it) } - } + override fun list(params: FunctionListParams, requestOptions: RequestOptions): FunctionListPage { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + FunctionListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a function object by its id */ override fun delete(params: FunctionDeleteParams, requestOptions: RequestOptions): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "function", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "function", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace function. If there is an existing function in the project with the same - * slug as the one specified in the request, will replace the existing function with the - * provided fields + * Create or replace function. If there is an existing function in the project with + * the same slug as the one specified in the request, will replace the existing + * function with the provided fields */ override fun replace(params: FunctionReplaceParams, requestOptions: RequestOptions): Function { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "function") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "function") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt index 887eabcc..6f06cf8d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams @@ -13,55 +28,55 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface GroupService { /** - * Create a new group. If there is an existing group with the same name as the one specified in - * the request, will return the existing group unmodified + * 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, - 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, - 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, - 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( - params: GroupListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): GroupListPage + fun list(params: GroupListParams, requestOptions: RequestOptions = RequestOptions.none()): GroupListPage /** Delete a group object by its id */ - 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, - requestOptions: RequestOptions = RequestOptions.none() - ): Group + fun replace(params: GroupReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Group } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt index 013bad2a..9188c83a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/GroupServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Group import com.braintrustdata.api.models.GroupCreateParams import com.braintrustdata.api.models.GroupDeleteParams @@ -16,183 +26,212 @@ import com.braintrustdata.api.models.GroupListParams import com.braintrustdata.api.models.GroupReplaceParams import com.braintrustdata.api.models.GroupRetrieveParams import com.braintrustdata.api.models.GroupUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class GroupServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : GroupService { +class GroupServiceImpl constructor(private val clientOptions: ClientOptions, ) : GroupService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new group. If there is an existing group with the same name as the one specified in - * the request, will return the existing group unmodified + * Create a new group. If there is an existing group with the same name as the one + * specified in the request, will return the existing group unmodified */ override fun create(params: GroupCreateParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a group object by its id */ override fun retrieve(params: GroupRetrieveParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a group object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a group object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ override fun update(params: GroupUpdateParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ override fun list(params: GroupListParams, requestOptions: RequestOptions): GroupListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { GroupListPage.of(this, params, it) } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + GroupListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a group object by its id */ override fun delete(params: GroupDeleteParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "group", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "group", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace group. If there is an existing group with the same name as the one - * specified in the request, will replace the existing group with the provided fields + * Create or replace group. If there is an existing group with the same name as the + * one specified in the request, will replace the existing group with the provided + * fields */ override fun replace(params: GroupReplaceParams, requestOptions: RequestOptions): Group { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "group") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "group") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrgSecretService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrgSecretService.kt index b940c419..a5dcf000 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrgSecretService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrgSecretService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.OrgSecret import com.braintrustdata.api.models.OrgSecretCreateParams import com.braintrustdata.api.models.OrgSecretDeleteParams @@ -13,55 +28,56 @@ import com.braintrustdata.api.models.OrgSecretListParams import com.braintrustdata.api.models.OrgSecretReplaceParams import com.braintrustdata.api.models.OrgSecretRetrieveParams import com.braintrustdata.api.models.OrgSecretUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface OrgSecretService { /** - * Create a new org_secret. If there is an existing org_secret with the same name as the one - * specified in the request, will return the existing org_secret unmodified + * Create a new org_secret. If there is an existing org_secret with the same name + * as the one specified in the request, will return the existing org_secret + * unmodified */ - fun create( - params: OrgSecretCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecret + fun create(params: OrgSecretCreateParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecret /** Get an org_secret object by its id */ - fun retrieve( - params: OrgSecretRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecret + fun retrieve(params: OrgSecretRetrieveParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecret /** - * Partially update an org_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 org_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: OrgSecretUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecret + fun update(params: OrgSecretUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecret /** - * List out all org_secrets. The org_secrets are sorted by creation date, with the most - * recently-created org_secrets coming first + * List out all org_secrets. The org_secrets are sorted by creation date, with the + * most recently-created org_secrets coming first */ - fun list( - params: OrgSecretListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecretListPage + fun list(params: OrgSecretListParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecretListPage /** Delete an org_secret object by its id */ - fun delete( - params: OrgSecretDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecret + fun delete(params: OrgSecretDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecret /** - * Create or replace org_secret. If there is an existing org_secret with the same name as the - * one specified in the request, will replace the existing org_secret with the provided fields + * Create or replace org_secret. If there is an existing org_secret with the same + * name as the one specified in the request, will replace the existing org_secret + * with the provided fields */ - fun replace( - params: OrgSecretReplaceParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrgSecret + fun replace(params: OrgSecretReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): OrgSecret } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrgSecretServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrgSecretServiceImpl.kt index e3430108..b72e9fbc 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrgSecretServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrgSecretServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.OrgSecret import com.braintrustdata.api.models.OrgSecretCreateParams import com.braintrustdata.api.models.OrgSecretDeleteParams @@ -16,193 +26,213 @@ import com.braintrustdata.api.models.OrgSecretListParams import com.braintrustdata.api.models.OrgSecretReplaceParams import com.braintrustdata.api.models.OrgSecretRetrieveParams import com.braintrustdata.api.models.OrgSecretUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class OrgSecretServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : OrgSecretService { +class OrgSecretServiceImpl constructor(private val clientOptions: ClientOptions, ) : OrgSecretService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new org_secret. If there is an existing org_secret with the same name as the one - * specified in the request, will return the existing org_secret unmodified + * Create a new org_secret. If there is an existing org_secret with the same name + * as the one specified in the request, will return the existing org_secret + * unmodified */ override fun create(params: OrgSecretCreateParams, requestOptions: RequestOptions): OrgSecret { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "org_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "org_secret") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get an org_secret object by its id */ - override fun retrieve( - params: OrgSecretRetrieveParams, - requestOptions: RequestOptions - ): OrgSecret { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "org_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve(params: OrgSecretRetrieveParams, requestOptions: RequestOptions): OrgSecret { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "org_secret", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update an org_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 org_secret object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ override fun update(params: OrgSecretUpdateParams, requestOptions: RequestOptions): OrgSecret { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "org_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "org_secret", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all org_secrets. The org_secrets are sorted by creation date, with the most - * recently-created org_secrets coming first + * List out all org_secrets. The org_secrets are sorted by creation date, with the + * most recently-created org_secrets coming first */ - override fun list( - params: OrgSecretListParams, - requestOptions: RequestOptions - ): OrgSecretListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "org_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { OrgSecretListPage.of(this, params, it) } - } + override fun list(params: OrgSecretListParams, requestOptions: RequestOptions): OrgSecretListPage { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "org_secret") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + OrgSecretListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete an org_secret object by its id */ override fun delete(params: OrgSecretDeleteParams, requestOptions: RequestOptions): OrgSecret { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "org_secret", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "org_secret", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace org_secret. If there is an existing org_secret with the same name as the - * one specified in the request, will replace the existing org_secret with the provided fields + * Create or replace org_secret. If there is an existing org_secret with the same + * name as the one specified in the request, will replace the existing org_secret + * with the provided fields */ - override fun replace( - params: OrgSecretReplaceParams, - requestOptions: RequestOptions - ): OrgSecret { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "org_secret") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace(params: OrgSecretReplaceParams, requestOptions: RequestOptions): OrgSecret { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "org_secret") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt index 18af9527..91462012 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationService.kt @@ -4,47 +4,68 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListPage import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler import com.braintrustdata.api.services.blocking.organization.MemberService +import com.braintrustdata.api.services.blocking.organization.MemberServiceImpl interface OrganizationService { fun members(): MemberService /** Get an organization object by its id */ - 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, - 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( - params: OrganizationListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrganizationListPage + fun list(params: OrganizationListParams, requestOptions: RequestOptions = RequestOptions.none()): OrganizationListPage /** Delete an organization object by its id */ - fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Organization + fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Organization } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt index 55f20ed7..b122410c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceImpl.kt @@ -2,29 +2,49 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Organization import com.braintrustdata.api.models.OrganizationDeleteParams import com.braintrustdata.api.models.OrganizationListPage import com.braintrustdata.api.models.OrganizationListParams import com.braintrustdata.api.models.OrganizationRetrieveParams import com.braintrustdata.api.models.OrganizationUpdateParams -import com.braintrustdata.api.services.blocking.organization.MemberService -import com.braintrustdata.api.services.blocking.organization.MemberServiceImpl +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import com.braintrustdata.api.services.blocking.organization.MemberService +import com.braintrustdata.api.services.blocking.organization.MemberServiceImpl -class OrganizationServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : OrganizationService { +class OrganizationServiceImpl constructor(private val clientOptions: ClientOptions, ) : OrganizationService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -33,125 +53,126 @@ constructor( override fun members(): MemberService = members private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get an organization object by its id */ - override fun retrieve( - params: OrganizationRetrieveParams, - requestOptions: RequestOptions - ): Organization { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve(params: OrganizationRetrieveParams, requestOptions: RequestOptions): Organization { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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. */ - override fun update( - params: OrganizationUpdateParams, - requestOptions: RequestOptions - ): Organization { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update(params: OrganizationUpdateParams, requestOptions: RequestOptions): Organization { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override fun list( - params: OrganizationListParams, - requestOptions: RequestOptions - ): OrganizationListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "organization") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { OrganizationListPage.of(this, params, it) } - } + override fun list(params: OrganizationListParams, requestOptions: RequestOptions): OrganizationListPage { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "organization") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + OrganizationListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete an organization object by its id */ - override fun delete( - params: OrganizationDeleteParams, - requestOptions: RequestOptions - ): Organization { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "organization", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override fun delete(params: OrganizationDeleteParams, requestOptions: RequestOptions): Organization { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "organization", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt index c47694a9..2dbb401e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams @@ -13,57 +28,56 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface ProjectScoreService { /** - * 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, - 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, - 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, - 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( - params: ProjectScoreListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectScoreListPage + fun list(params: ProjectScoreListParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScoreListPage /** Delete a project_score object by its id */ - 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, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectScore + fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectScore } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt index ec231f82..a889fbbd 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ProjectScore import com.braintrustdata.api.models.ProjectScoreCreateParams import com.braintrustdata.api.models.ProjectScoreDeleteParams @@ -16,204 +26,213 @@ import com.braintrustdata.api.models.ProjectScoreListParams import com.braintrustdata.api.models.ProjectScoreReplaceParams import com.braintrustdata.api.models.ProjectScoreRetrieveParams import com.braintrustdata.api.models.ProjectScoreUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ProjectScoreServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : ProjectScoreService { +class ProjectScoreServiceImpl constructor(private val clientOptions: ClientOptions, ) : ProjectScoreService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override fun create( - params: ProjectScoreCreateParams, - requestOptions: RequestOptions - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create(params: ProjectScoreCreateParams, requestOptions: RequestOptions): ProjectScore { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a project_score object by its id */ - override fun retrieve( - params: ProjectScoreRetrieveParams, - requestOptions: RequestOptions - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve(params: ProjectScoreRetrieveParams, requestOptions: RequestOptions): ProjectScore { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a project_score object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_score object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - override fun update( - params: ProjectScoreUpdateParams, - requestOptions: RequestOptions - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update(params: ProjectScoreUpdateParams, requestOptions: RequestOptions): ProjectScore { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all project_scores. The project_scores are sorted by creation date, with the most - * recently-created project_scores coming first + * List out all project_scores. The project_scores are sorted by creation date, + * with the most recently-created project_scores coming first */ - override fun list( - params: ProjectScoreListParams, - requestOptions: RequestOptions - ): ProjectScoreListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ProjectScoreListPage.of(this, params, it) } - } + override fun list(params: ProjectScoreListParams, requestOptions: RequestOptions): ProjectScoreListPage { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ProjectScoreListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a project_score object by its id */ - override fun delete( - params: ProjectScoreDeleteParams, - requestOptions: RequestOptions - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_score", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override fun delete(params: ProjectScoreDeleteParams, requestOptions: RequestOptions): ProjectScore { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_score", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override fun replace( - params: ProjectScoreReplaceParams, - requestOptions: RequestOptions - ): ProjectScore { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_score") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace(params: ProjectScoreReplaceParams, requestOptions: RequestOptions): ProjectScore { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_score") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt index 12caa984..668ce61c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams @@ -12,49 +27,52 @@ import com.braintrustdata.api.models.ProjectListPage import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler import com.braintrustdata.api.services.blocking.project.LogService +import com.braintrustdata.api.services.blocking.project.LogServiceImpl interface ProjectService { 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, - 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, - 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, - 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 * recently-created projects coming first */ - fun list( - params: ProjectListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectListPage + fun list(params: ProjectListParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectListPage /** Delete a project object by its id */ - fun delete( - params: ProjectDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): Project + fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions = RequestOptions.none()): Project } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt index 30b3e218..8557508a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Project import com.braintrustdata.api.models.ProjectCreateParams import com.braintrustdata.api.models.ProjectDeleteParams @@ -15,17 +25,27 @@ import com.braintrustdata.api.models.ProjectListPage import com.braintrustdata.api.models.ProjectListParams import com.braintrustdata.api.models.ProjectRetrieveParams import com.braintrustdata.api.models.ProjectUpdateParams -import com.braintrustdata.api.services.blocking.project.LogService -import com.braintrustdata.api.services.blocking.project.LogServiceImpl +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler +import com.braintrustdata.api.services.blocking.project.LogService +import com.braintrustdata.api.services.blocking.project.LogServiceImpl -class ProjectServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : ProjectService { +class ProjectServiceImpl constructor(private val clientOptions: ClientOptions, ) : ProjectService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) @@ -34,142 +54,157 @@ constructor( override fun logs(): LogService = logs private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new project. If there is an existing project with the same name as the one specified - * in the request, will return the existing project unmodified + * Create a new project. If there is an existing project with the same name as the + * one specified in the request, will return the existing project unmodified */ override fun create(params: ProjectCreateParams, requestOptions: RequestOptions): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a project object by its id */ override fun retrieve(params: ProjectRetrieveParams, requestOptions: RequestOptions): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a project object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ override fun update(params: ProjectUpdateParams, requestOptions: RequestOptions): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** * List out all projects. The projects are sorted by creation date, with the most * recently-created projects coming first */ override fun list(params: ProjectListParams, requestOptions: RequestOptions): ProjectListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ProjectListPage.of(this, params, it) } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ProjectListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a project object by its id */ override fun delete(params: ProjectDeleteParams, requestOptions: RequestOptions): Project { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt index 9bc7c2f9..ecd26553 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams @@ -13,56 +28,56 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface ProjectTagService { /** - * Create a new project_tag. If there is an existing project_tag in the project with the same - * name as the one specified in the request, will return the existing project_tag unmodified + * 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, - 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, - 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, - 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( - params: ProjectTagListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectTagListPage + fun list(params: ProjectTagListParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTagListPage /** Delete a project_tag object by its id */ - 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, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectTag + fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): ProjectTag } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt index 58d595aa..a5f6df9f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.ProjectTag import com.braintrustdata.api.models.ProjectTagCreateParams import com.braintrustdata.api.models.ProjectTagDeleteParams @@ -16,203 +26,213 @@ import com.braintrustdata.api.models.ProjectTagListParams import com.braintrustdata.api.models.ProjectTagReplaceParams import com.braintrustdata.api.models.ProjectTagRetrieveParams import com.braintrustdata.api.models.ProjectTagUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ProjectTagServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : ProjectTagService { +class ProjectTagServiceImpl constructor(private val clientOptions: ClientOptions, ) : ProjectTagService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override fun create( - params: ProjectTagCreateParams, - requestOptions: RequestOptions - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun create(params: ProjectTagCreateParams, requestOptions: RequestOptions): ProjectTag { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a project_tag object by its id */ - override fun retrieve( - params: ProjectTagRetrieveParams, - requestOptions: RequestOptions - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun retrieve(params: ProjectTagRetrieveParams, requestOptions: RequestOptions): ProjectTag { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a project_tag object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a project_tag object. Specify the fields to update in the + * payload. Any object-type fields will be deep-merged with existing content. + * Currently we do not support removing fields or setting them to null. */ - override fun update( - params: ProjectTagUpdateParams, - requestOptions: RequestOptions - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update(params: ProjectTagUpdateParams, requestOptions: RequestOptions): ProjectTag { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * List out all project_tags. The project_tags are sorted by creation date, with the most - * recently-created project_tags coming first + * List out all project_tags. The project_tags are sorted by creation date, with + * the most recently-created project_tags coming first */ - override fun list( - params: ProjectTagListParams, - requestOptions: RequestOptions - ): ProjectTagListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ProjectTagListPage.of(this, params, it) } - } + override fun list(params: ProjectTagListParams, requestOptions: RequestOptions): ProjectTagListPage { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ProjectTagListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a project_tag object by its id */ - override fun delete( - params: ProjectTagDeleteParams, - requestOptions: RequestOptions - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "project_tag", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + override fun delete(params: ProjectTagDeleteParams, requestOptions: RequestOptions): ProjectTag { + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "project_tag", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ - override fun replace( - params: ProjectTagReplaceParams, - requestOptions: RequestOptions - ): ProjectTag { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "project_tag") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun replace(params: ProjectTagReplaceParams, requestOptions: RequestOptions): ProjectTag { + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "project_tag") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt index 7a500e3c..ea55ebb7 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams @@ -13,55 +28,56 @@ import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface PromptService { /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will return the existing prompt unmodified + * 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, - 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, - 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, - 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( - params: PromptListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): PromptListPage + fun list(params: PromptListParams, requestOptions: RequestOptions = RequestOptions.none()): PromptListPage /** Delete a prompt object by its id */ - 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, - requestOptions: RequestOptions = RequestOptions.none() - ): Prompt + fun replace(params: PromptReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Prompt } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt index f69ae3bb..67eebc1a 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/PromptServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Prompt import com.braintrustdata.api.models.PromptCreateParams import com.braintrustdata.api.models.PromptDeleteParams @@ -16,184 +26,213 @@ import com.braintrustdata.api.models.PromptListParams import com.braintrustdata.api.models.PromptReplaceParams import com.braintrustdata.api.models.PromptRetrieveParams import com.braintrustdata.api.models.PromptUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class PromptServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : PromptService { +class PromptServiceImpl constructor(private val clientOptions: ClientOptions, ) : PromptService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new prompt. If there is an existing prompt in the project with the same slug as the - * one specified in the request, will return the existing prompt unmodified + * Create a new prompt. If there is an existing prompt in the project with the same + * slug as the one specified in the request, will return the existing prompt + * unmodified */ override fun create(params: PromptCreateParams, requestOptions: RequestOptions): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a prompt object by its id */ override fun retrieve(params: PromptRetrieveParams, requestOptions: RequestOptions): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a prompt object. Specify the fields to update in the payload. Any - * object-type fields will be deep-merged with existing content. Currently we do not support - * removing fields or setting them to null. + * Partially update a prompt object. Specify the fields to update in the payload. + * Any object-type fields will be deep-merged with existing content. Currently we + * do not support removing fields or setting them to null. */ override fun update(params: PromptUpdateParams, requestOptions: RequestOptions): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ override fun list(params: PromptListParams, requestOptions: RequestOptions): PromptListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { PromptListPage.of(this, params, it) } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + PromptListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a prompt object by its id */ override fun delete(params: PromptDeleteParams, requestOptions: RequestOptions): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "prompt", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "prompt", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace prompt. If there is an existing prompt in the project with the same slug as - * the one specified in the request, will replace the existing prompt with the provided fields + * Create or replace prompt. If there is an existing prompt in the project with the + * same slug as the one specified in the request, will replace the existing prompt + * with the provided fields */ override fun replace(params: PromptReplaceParams, requestOptions: RequestOptions): Prompt { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "prompt") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "prompt") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt index db855e06..7a85849f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams @@ -13,55 +28,55 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface RoleService { /** - * Create a new role. If there is an existing role with the same name as the one specified in - * the request, will return the existing role unmodified + * 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, - 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, - 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, - 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( - params: RoleListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): RoleListPage + fun list(params: RoleListParams, requestOptions: RequestOptions = RequestOptions.none()): RoleListPage /** Delete a role object by its id */ - 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, - requestOptions: RequestOptions = RequestOptions.none() - ): Role + fun replace(params: RoleReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): Role } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt index 89bd2f20..8f7e920d 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/RoleServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.Role import com.braintrustdata.api.models.RoleCreateParams import com.braintrustdata.api.models.RoleDeleteParams @@ -16,183 +26,212 @@ import com.braintrustdata.api.models.RoleListParams import com.braintrustdata.api.models.RoleReplaceParams import com.braintrustdata.api.models.RoleRetrieveParams import com.braintrustdata.api.models.RoleUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class RoleServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : RoleService { +class RoleServiceImpl constructor(private val clientOptions: ClientOptions, ) : RoleService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new role. If there is an existing role with the same name as the one specified in - * the request, will return the existing role unmodified + * Create a new role. If there is an existing role with the same name as the one + * specified in the request, will return the existing role unmodified */ override fun create(params: RoleCreateParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a role object by its id */ override fun retrieve(params: RoleRetrieveParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a role object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a role object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ override fun update(params: RoleUpdateParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ override fun list(params: RoleListParams, requestOptions: RequestOptions): RoleListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { RoleListPage.of(this, params, it) } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + RoleListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a role object by its id */ override fun delete(params: RoleDeleteParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "role", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "role", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { + params.getBody()?.also { + body(json(clientOptions.jsonMapper, it)) + } } + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace role. If there is an existing role with the same name as the one specified - * in the request, will replace the existing role with the provided fields + * Create or replace role. If there is an existing role with the same name as the + * one specified in the request, will replace the existing role with the provided + * fields */ override fun replace(params: RoleReplaceParams, requestOptions: RequestOptions): Role { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "role") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "role") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt index c0972232..03c76544 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelService.kt @@ -4,14 +4,46 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.TopLevelHelloWorldParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface TopLevelService { - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ - fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions = RequestOptions.none() - ): String + /** + * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not + * required + */ + fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions = RequestOptions.none()): String } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt index 631eac96..051a7f2e 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceImpl.kt @@ -2,42 +2,67 @@ package com.braintrustdata.api.services.blocking +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.TopLevelHelloWorldParams import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.TopLevelHelloWorldParams +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class TopLevelServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : TopLevelService { +class TopLevelServiceImpl constructor(private val clientOptions: ClientOptions, ) : TopLevelService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val helloWorldHandler: Handler = stringHandler().withErrorHandler(errorHandler) + private val helloWorldHandler: Handler = + stringHandler() + .withErrorHandler(errorHandler) - /** Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required */ - override fun helloWorld( - params: TopLevelHelloWorldParams, - requestOptions: RequestOptions - ): String { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response.use { helloWorldHandler.handle(it) } - } + /** + * Default endpoint. Simply replies with 'Hello, World!'. Authorization is not + * required + */ + override fun helloWorld(params: TopLevelHelloWorldParams, requestOptions: RequestOptions): String { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + helloWorldHandler.handle(it) + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt index 70e079b2..a047033c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserService.kt @@ -4,26 +4,52 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.User import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListParams import com.braintrustdata.api.models.UserRetrieveParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface UserService { /** Get a user object by its id */ - 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( - params: UserListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): UserListPage + fun list(params: UserListParams, requestOptions: RequestOptions = RequestOptions.none()): UserListPage } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt index 28ff5d7a..0f20d0e8 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/UserServiceImpl.kt @@ -2,78 +2,105 @@ package com.braintrustdata.api.services.blocking +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.User +import com.braintrustdata.api.models.UserListPage +import com.braintrustdata.api.models.UserListParams +import com.braintrustdata.api.models.UserRetrieveParams import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.User -import com.braintrustdata.api.models.UserListPage -import com.braintrustdata.api.models.UserListParams -import com.braintrustdata.api.models.UserRetrieveParams +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class UserServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : UserService { +class UserServiceImpl constructor(private val clientOptions: ClientOptions, ) : UserService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a user object by its id */ override fun retrieve(params: UserRetrieveParams, requestOptions: RequestOptions): User { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ override fun list(params: UserListParams, requestOptions: RequestOptions): UserListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "user") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { UserListPage.of(this, params, it) } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "user") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + UserListPage.of(this, params, it) + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt index 4f19295d..010b6742 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams @@ -13,55 +28,55 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface ViewService { /** - * Create a new view. If there is an existing view with the same name as the one specified in - * the request, will return the existing view unmodified + * 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, - 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, - 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, - 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, - 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, - 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, - requestOptions: RequestOptions = RequestOptions.none() - ): View + fun replace(params: ViewReplaceParams, requestOptions: RequestOptions = RequestOptions.none()): View } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt index f682e6d6..47f6c81f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/ViewServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.View import com.braintrustdata.api.models.ViewCreateParams import com.braintrustdata.api.models.ViewDeleteParams @@ -16,183 +26,208 @@ import com.braintrustdata.api.models.ViewListParams import com.braintrustdata.api.models.ViewReplaceParams import com.braintrustdata.api.models.ViewRetrieveParams import com.braintrustdata.api.models.ViewUpdateParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class ViewServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : ViewService { +class ViewServiceImpl constructor(private val clientOptions: ClientOptions, ) : ViewService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create a new view. If there is an existing view with the same name as the one specified in - * the request, will return the existing view unmodified + * Create a new view. If there is an existing view with the same name as the one + * specified in the request, will return the existing view unmodified */ override fun create(params: ViewCreateParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + createHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Get a view object by its id */ override fun retrieve(params: ViewRetrieveParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + retrieveHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Partially update a view object. Specify the fields to update in the payload. Any object-type - * fields will be deep-merged with existing content. Currently we do not support removing fields - * or setting them to null. + * Partially update a view object. Specify the fields to update in the payload. Any + * object-type fields will be deep-merged with existing content. Currently we do + * not support removing fields or setting them to null. */ override fun update(params: ViewUpdateParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * 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 */ override fun list(params: ViewListParams, requestOptions: RequestOptions): ViewListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - .let { ViewListPage.of(this, params, it) } - } + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + listHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { + ViewListPage.of(this, params, it) + } + } } private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Delete a view object by its id */ override fun delete(params: ViewDeleteParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("v1", "view", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { deleteHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("v1", "view", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + deleteHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Create or replace view. If there is an existing view with the same name as the one specified - * in the request, will replace the existing view with the provided fields + * Create or replace view. If there is an existing view with the same name as the + * one specified in the request, will replace the existing view with the provided + * fields */ override fun replace(params: ViewReplaceParams, requestOptions: RequestOptions): View { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("v1", "view") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { replaceHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + val request = HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("v1", "view") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + replaceHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberService.kt index a4c445fc..555cc01c 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberService.kt @@ -4,15 +4,44 @@ package com.braintrustdata.api.services.blocking.organization -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.OrganizationMemberUpdateParams import com.braintrustdata.api.models.OrganizationMemberUpdateResponse +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface MemberService { /** Modify organization membership */ - fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrganizationMemberUpdateResponse + fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions = RequestOptions.none()): OrganizationMemberUpdateResponse } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceImpl.kt index bad7cfde..21d94dbd 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceImpl.kt @@ -2,53 +2,71 @@ package com.braintrustdata.api.services.blocking.organization +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.models.OrganizationMemberUpdateParams +import com.braintrustdata.api.models.OrganizationMemberUpdateResponse import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.core.http.HttpMethod import com.braintrustdata.api.core.http.HttpRequest import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.OrganizationMemberUpdateParams -import com.braintrustdata.api.models.OrganizationMemberUpdateResponse +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class MemberServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : MemberService { +class MemberServiceImpl constructor(private val clientOptions: ClientOptions, ) : MemberService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Modify organization membership */ - override fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions - ): OrganizationMemberUpdateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun update(params: OrganizationMemberUpdateParams, requestOptions: RequestOptions): OrganizationMemberUpdateResponse { + val request = HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v1", "organization", "members") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + updateHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt deleted file mode 100755 index 9a2bea3d..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberService.kt +++ /dev/null @@ -1,18 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.braintrustdata.api.services.blocking.organizations - -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.models.OrganizationMemberUpdateParams -import com.braintrustdata.api.models.OrganizationMemberUpdateResponse - -interface MemberService { - - /** Modify organization membership */ - fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): OrganizationMemberUpdateResponse -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt deleted file mode 100755 index b8126ca9..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceImpl.kt +++ /dev/null @@ -1,54 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.blocking.organizations - -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.OrganizationMemberUpdateParams -import com.braintrustdata.api.models.OrganizationMemberUpdateResponse -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler - -class MemberServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : MemberService { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Modify organization membership */ - override fun update( - params: OrganizationMemberUpdateParams, - requestOptions: RequestOptions - ): OrganizationMemberUpdateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .addPathSegments("v1", "organization", "members") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogService.kt index 4507495e..692ad932 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogService.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogService.kt @@ -4,7 +4,22 @@ package com.braintrustdata.api.services.blocking.project -import com.braintrustdata.api.core.RequestOptions +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse import com.braintrustdata.api.models.InsertEventsResponse @@ -12,36 +27,41 @@ import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler +import com.braintrustdata.api.services.errorHandler +import com.braintrustdata.api.services.json +import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler +import com.braintrustdata.api.services.withErrorHandler interface LogService { /** Log feedback for a set of project logs events */ - 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 + * 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 */ - 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 + * 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 */ - 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, - requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse + fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions = RequestOptions.none()): InsertEventsResponse } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceImpl.kt index a1760524..7c5d083f 100755 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceImpl.kt +++ b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceImpl.kt @@ -2,12 +2,22 @@ package com.braintrustdata.api.services.blocking.project -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import kotlin.LazyThreadSafetyMode.PUBLICATION +import java.time.LocalDate +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.stream.Stream +import com.braintrustdata.api.core.Enum +import com.braintrustdata.api.core.NoAutoDetect +import com.braintrustdata.api.errors.BraintrustInvalidDataException import com.braintrustdata.api.models.FeedbackResponseSchema import com.braintrustdata.api.models.FetchProjectLogsEventsResponse import com.braintrustdata.api.models.InsertEventsResponse @@ -15,138 +25,142 @@ import com.braintrustdata.api.models.ProjectLogFeedbackParams import com.braintrustdata.api.models.ProjectLogFetchParams import com.braintrustdata.api.models.ProjectLogFetchPostParams import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.core.ClientOptions +import com.braintrustdata.api.core.http.HttpMethod +import com.braintrustdata.api.core.http.HttpRequest +import com.braintrustdata.api.core.http.HttpResponse.Handler +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.core.JsonField +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.RequestOptions +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.services.emptyHandler import com.braintrustdata.api.services.errorHandler import com.braintrustdata.api.services.json import com.braintrustdata.api.services.jsonHandler +import com.braintrustdata.api.services.multipartFormData +import com.braintrustdata.api.services.stringHandler +import com.braintrustdata.api.services.binaryHandler import com.braintrustdata.api.services.withErrorHandler -class LogServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : LogService { +class LogServiceImpl constructor(private val clientOptions: ClientOptions, ) : LogService { private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val feedbackHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Log feedback for a set of project logs events */ - override fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions - ): FeedbackResponseSchema { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { feedbackHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions): FeedbackResponseSchema { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + feedbackHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body + * 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 */ - override fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions - ): FetchProjectLogsEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetch(params: ProjectLogFetchParams, requestOptions: RequestOptions): FetchProjectLogsEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + fetchHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query + * 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 */ - override fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions - ): FetchProjectLogsEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun fetchPost(params: ProjectLogFetchPostParams, requestOptions: RequestOptions): FetchProjectLogsEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + fetchPostHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) /** Insert a set of events into the project logs */ - override fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } + override fun insert(params: ProjectLogInsertParams, requestOptions: RequestOptions): InsertEventsResponse { + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions) + .let { response -> + response.use { + insertHandler.handle(it) + } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } } } diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt deleted file mode 100755 index 3803c459..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogService.kt +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.braintrustdata.api.services.blocking.projects - -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse -import com.braintrustdata.api.models.ProjectLogFeedbackParams -import com.braintrustdata.api.models.ProjectLogFetchParams -import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogInsertParams - -interface LogService { - - /** Log feedback for a set of project logs events */ - fun feedback( - params: ProjectLogFeedbackParams, - requestOptions: RequestOptions = RequestOptions.none() - ) - - /** - * 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 - */ - 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 - */ - fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions = RequestOptions.none() - ): FetchProjectLogsEventsResponse - - /** Insert a set of events into the project logs */ - fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions = RequestOptions.none() - ): InsertEventsResponse -} diff --git a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt b/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt deleted file mode 100755 index 07baf950..00000000 --- a/braintrust-kotlin-core/src/main/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceImpl.kt +++ /dev/null @@ -1,142 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.blocking.projects - -import com.braintrustdata.api.core.ClientOptions -import com.braintrustdata.api.core.RequestOptions -import com.braintrustdata.api.core.http.HttpMethod -import com.braintrustdata.api.core.http.HttpRequest -import com.braintrustdata.api.core.http.HttpResponse.Handler -import com.braintrustdata.api.errors.BraintrustError -import com.braintrustdata.api.models.FetchProjectLogsEventsResponse -import com.braintrustdata.api.models.InsertEventsResponse -import com.braintrustdata.api.models.ProjectLogFeedbackParams -import com.braintrustdata.api.models.ProjectLogFetchParams -import com.braintrustdata.api.models.ProjectLogFetchPostParams -import com.braintrustdata.api.models.ProjectLogInsertParams -import com.braintrustdata.api.services.emptyHandler -import com.braintrustdata.api.services.errorHandler -import com.braintrustdata.api.services.json -import com.braintrustdata.api.services.jsonHandler -import com.braintrustdata.api.services.withErrorHandler - -class LogServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : LogService { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val feedbackHandler: Handler = emptyHandler().withErrorHandler(errorHandler) - - /** Log feedback for a set of project logs events */ - override fun feedback(params: ProjectLogFeedbackParams, requestOptions: RequestOptions) { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "feedback") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - clientOptions.httpClient.execute(request, requestOptions).let { response -> - response.use { feedbackHandler.handle(it) } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the POST form of the same path, but with - * the parameters in the URL query rather than in the request body - */ - override fun fetch( - params: ProjectLogFetchParams, - requestOptions: RequestOptions - ): FetchProjectLogsEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val fetchPostHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the - * parameters in the request body rather than in the URL query - */ - override fun fetchPost( - params: ProjectLogFetchPostParams, - requestOptions: RequestOptions - ): FetchProjectLogsEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "fetch") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { fetchPostHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } - - private val insertHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Insert a set of events into the project logs */ - override fun insert( - params: ProjectLogInsertParams, - requestOptions: RequestOptions - ): InsertEventsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("v1", "project_logs", params.getPathParam(0), "insert") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { insertHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt index d79a0c57..bfb17770 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/TestServerExtension.kt @@ -43,13 +43,9 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt index 8c937928..79c4a820 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/HttpRequestTest.kt @@ -1,22 +1,20 @@ package com.braintrustdata.api.core.http -import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat internal class HttpRequestTest { @Test fun caseInsensitiveHeadersAccessors() { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .putHeader("something_lowercase", "lowercase") - .putHeader("Something_Capitalized", "Capitalized") - .putHeader("SOMETHING_UPPERCASE", "UPPERCASE") - .build() + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .putHeader("something_lowercase", "lowercase") + .putHeader("Something_Capitalized", "Capitalized") + .putHeader("SOMETHING_UPPERCASE", "UPPERCASE") + .build() assertThat(request.headers.get("SOMETHING_LOWERCASE").getOrNull(0)).isEqualTo("lowercase") - assertThat(request.headers.get("something_capitalized").getOrNull(0)) - .isEqualTo("Capitalized") + assertThat(request.headers.get("something_capitalized").getOrNull(0)).isEqualTo("Capitalized") assertThat(request.headers.get("Something_Uppercase").getOrNull(0)).isEqualTo("UPPERCASE") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt index 821404b6..ab1470f4 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/RetryingHttpClientTest.kt @@ -1,13 +1,14 @@ package com.braintrustdata.api.core.http -import com.braintrustdata.api.client.okhttp.OkHttpClient -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 org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.client.okhttp.OkHttpClient import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy +import com.github.tomakehurst.wiremock.stubbing.Scenario +import com.github.tomakehurst.wiremock.client.WireMock.* @WireMockTest internal class RetryingHttpClientTest { @@ -16,16 +17,25 @@ internal class RetryingHttpClientTest { @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - httpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + httpClient = OkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .build() resetAllScenarios() } @Test fun byDefaultShouldNotAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() - stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegment("something") + .build() + stubFor( + post(urlPathEqualTo("/something")) + .willReturn(ok()) + ) + val retryingClient = RetryingHttpClient.builder() + .httpClient(httpClient) + .build() val response = retryingClient.execute(request) assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) @@ -33,18 +43,19 @@ internal class RetryingHttpClientTest { @Test fun whenProvidedShouldAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegment("something") + .build() stubFor( post(urlPathEqualTo("/something")) .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) .willReturn(ok()) ) - val retryingClient = - RetryingHttpClient.builder() - .httpClient(httpClient) - .idempotencyHeader("X-Some-Header") - .build() + val retryingClient = RetryingHttpClient.builder() + .httpClient(httpClient) + .idempotencyHeader("X-Some-Header") + .build() val response = retryingClient.execute(request) assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) @@ -52,15 +63,15 @@ internal class RetryingHttpClientTest { @Test fun retryAfterHeader() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegment("something") + .build() stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT")) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -77,8 +88,10 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val retryingClient = RetryingHttpClient.builder() + .httpClient(httpClient) + .maxRetries(2) + .build() val response = retryingClient.execute(request) assertThat(response.statusCode()).isEqualTo(200) verify(3, postRequestedFor(urlPathEqualTo("/something"))) @@ -86,8 +99,10 @@ internal class RetryingHttpClientTest { @Test fun retryAfterMsHeader() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + val request = HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegment("something") + .build() stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") @@ -102,8 +117,10 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val retryingClient = RetryingHttpClient.builder() + .httpClient(httpClient) + .maxRetries(2) + .build() val response = retryingClient.execute(request) assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt index f1c1f965..eb6a3341 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/core/http/SerializerTest.kt +++ b/braintrust-kotlin-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,30 +44,28 @@ 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() } @NoAutoDetect - class Builder { + class Builder{ private var isActive: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -73,7 +73,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() @@ -89,14 +91,14 @@ internal class SerializerTest { this.additionalProperties.putAll(additionalProperties) } - fun build(): ClassWithBooleanFieldPrefixedWithIs = - ClassWithBooleanFieldPrefixedWithIs( - isActive, - additionalProperties.toUnmodifiable(), - ) + fun build(): ClassWithBooleanFieldPrefixedWithIs = ClassWithBooleanFieldPrefixedWithIs( + isActive, + additionalProperties.toUnmodifiable(), + ) } } + @Test fun serializeBooleanPrefixedWithIs() { val value = ClassWithBooleanFieldPrefixedWithIs.builder().isActive(true).build() diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt index 87112c2c..a40d5568 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclCreateParamsTest.kt @@ -2,55 +2,66 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.AclCreateParams +import com.braintrustdata.api.models.AclCreateParams.AclCreateBody class AclCreateParamsTest { @Test fun createAclCreateParams() { - 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 getBody() { - 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.getBody() - assertThat(body).isNotNull - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) - assertThat(body.groupId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.permission()).isEqualTo(AclCreateParams.Permission.CREATE) - assertThat(body.restrictObjectType()) - .isEqualTo(AclCreateParams.RestrictObjectType.ORGANIZATION) - assertThat(body.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.userId()).isEqualTo("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.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(AclCreateParams.ObjectType.ORGANIZATION) + assertThat(body.groupId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.permission()).isEqualTo(AclCreateParams.Permission.CREATE) + assertThat(body.restrictObjectType()).isEqualTo(AclCreateParams.RestrictObjectType.ORGANIZATION) + assertThat(body.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun getBodyWithoutOptionalFields() { - val params = - AclCreateParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = AclCreateParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt index 5b65f5d1..4dc708af 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclDeleteParamsTest.kt @@ -2,24 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.AclDeleteParams class AclDeleteParamsTest { @Test fun createAclDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt index aa22dbbb..c78aaf51 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclListParamsTest.kt @@ -2,54 +2,62 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.AclListParams class AclListParamsTest { @Test fun createAclListParams() { - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .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(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - AclListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(AclListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(AclListParams.ObjectType.ORGANIZATION.toString())) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - ) - expected.put("limit", listOf("123")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(AclListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("object_type", listOf(AclListParams.ObjectType.ORGANIZATION.toString())) + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(AclListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = - AclListParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt index ed334cc7..5b77b914 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclRetrieveParamsTest.kt @@ -2,25 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.AclRetrieveParams class AclRetrieveParamsTest { @Test fun createAclRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt index 285b4fb8..a56d97c1 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/AclTest.kt @@ -2,37 +2,43 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.Acl 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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(acl.groupId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl.permission()).isEqualTo(Acl.Permission.CREATE) - assertThat(acl.restrictObjectType()).isEqualTo(Acl.RestrictObjectType.ORGANIZATION) - assertThat(acl.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(acl.userId()).isEqualTo("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(acl.groupId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(acl.permission()).isEqualTo(Acl.Permission.CREATE) + assertThat(acl.restrictObjectType()).isEqualTo(Acl.RestrictObjectType.ORGANIZATION) + assertThat(acl.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(acl.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt deleted file mode 100755 index 8c337a43..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateParamsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ApiKeyCreateParamsTest { - - @Test - fun createApiKeyCreateParams() { - ApiKeyCreateParams.builder().name("name").orgName("org_name").build() - } - - @Test - fun getBody() { - val params = ApiKeyCreateParams.builder().name("name").orgName("org_name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).isEqualTo("org_name") - } - - @Test - fun getBodyWithoutOptionalFields() { - val params = ApiKeyCreateParams.builder().name("name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponseTest.kt deleted file mode 100755 index 620716c0..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyCreateResponseTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ApiKeyCreateResponseTest { - - @Test - fun createApiKeyCreateResponse() { - val apiKeyCreateResponse = - ApiKeyCreateResponse.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(apiKeyCreateResponse).isNotNull - assertThat(apiKeyCreateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(apiKeyCreateResponse.key()).isEqualTo("key") - assertThat(apiKeyCreateResponse.name()).isEqualTo("name") - assertThat(apiKeyCreateResponse.previewName()).isEqualTo("preview_name") - assertThat(apiKeyCreateResponse.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(apiKeyCreateResponse.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(apiKeyCreateResponse.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt deleted file mode 100755 index bbcd063d..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyDeleteParamsTest.kt +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ApiKeyDeleteParamsTest { - - @Test - fun createApiKeyDeleteParams() { - 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("") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt deleted file mode 100755 index e749c8e0..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyListParamsTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ApiKeyListParamsTest { - - @Test - fun createApiKeyListParams() { - ApiKeyListParams.builder() - .apiKeyName("api_key_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - } - - @Test - fun getQueryParams() { - val params = - ApiKeyListParams.builder() - .apiKeyName("api_key_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("api_key_name", listOf("api_key_name")) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf(ApiKeyListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = ApiKeyListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParamsTest.kt index cbb7c684..f9e628ea 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceCreateParamsTest.kt @@ -2,31 +2,51 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ApiKeyResourceCreateParams +import com.braintrustdata.api.models.ApiKeyResourceCreateParams.ApiKeyResourceCreateBody class ApiKeyResourceCreateParamsTest { @Test fun createApiKeyResourceCreateParams() { - ApiKeyResourceCreateParams.builder().name("name").orgName("org_name").build() + ApiKeyResourceCreateParams.builder() + .name("name") + .orgName("org_name") + .build() } @Test fun getBody() { - val params = ApiKeyResourceCreateParams.builder().name("name").orgName("org_name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).isEqualTo("org_name") + val params = ApiKeyResourceCreateParams.builder() + .name("name") + .orgName("org_name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = ApiKeyResourceCreateParams.builder().name("name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = ApiKeyResourceCreateParams.builder() + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParamsTest.kt index d260995c..74e17c19 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceDeleteParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ApiKeyResourceDeleteParams class ApiKeyResourceDeleteParamsTest { @Test fun createApiKeyResourceDeleteParams() { - ApiKeyResourceDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ApiKeyResourceDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ApiKeyResourceDeleteParams.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 = ApiKeyResourceDeleteParams.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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParamsTest.kt index f02098fb..5ffa7533 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceListParamsTest.kt @@ -2,55 +2,59 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ApiKeyResourceListParams class ApiKeyResourceListParamsTest { @Test fun createApiKeyResourceListParams() { - ApiKeyResourceListParams.builder() - .apiKeyName("api_key_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ApiKeyResourceListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ApiKeyResourceListParams.builder() + .apiKeyName("api_key_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ApiKeyResourceListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - ApiKeyResourceListParams.builder() - .apiKeyName("api_key_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ApiKeyResourceListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("api_key_name", listOf("api_key_name")) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf( - ApiKeyResourceListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .toString() - ) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ApiKeyResourceListParams.builder() + .apiKeyName("api_key_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ApiKeyResourceListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("api_key_name", listOf("api_key_name")) + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(ApiKeyResourceListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = ApiKeyResourceListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ApiKeyResourceListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParamsTest.kt index 47b4cff8..4c486e8e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyResourceRetrieveParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ApiKeyResourceRetrieveParams class ApiKeyResourceRetrieveParamsTest { @Test fun createApiKeyResourceRetrieveParams() { - ApiKeyResourceRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ApiKeyResourceRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - ApiKeyResourceRetrieveParams.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 = ApiKeyResourceRetrieveParams.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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt deleted file mode 100755 index 48a5016b..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyRetrieveParamsTest.kt +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ApiKeyRetrieveParamsTest { - - @Test - fun createApiKeyRetrieveParams() { - 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("") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt index 52a3e5d0..ade45746 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ApiKeyTest.kt @@ -2,29 +2,35 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ApiKey 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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(apiKey.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(apiKey.userId()).isEqualTo("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKey.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKey.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateAclTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateAclTest.kt deleted file mode 100755 index a448e41f..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateAclTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreateAclTest { - - @Test - fun createCreateAcl() { - val createAcl = - CreateAcl.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(CreateAcl.ObjectType.ORGANIZATION) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .permission(CreateAcl.Permission.CREATE) - .restrictObjectType(CreateAcl.RestrictObjectType.ORGANIZATION) - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(createAcl).isNotNull - assertThat(createAcl.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createAcl.objectType()).isEqualTo(CreateAcl.ObjectType.ORGANIZATION) - assertThat(createAcl.groupId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createAcl.permission()).isEqualTo(CreateAcl.Permission.CREATE) - assertThat(createAcl.restrictObjectType()) - .isEqualTo(CreateAcl.RestrictObjectType.ORGANIZATION) - assertThat(createAcl.roleId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createAcl.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt index cad34456..0b778a90 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateApiKeyOutputTest.kt @@ -2,32 +2,37 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.CreateApiKeyOutput 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()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(createApiKeyOutput.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createApiKeyOutput.userId()).isEqualTo("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(createApiKeyOutput.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createApiKeyOutput.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateDatasetTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateDatasetTest.kt deleted file mode 100755 index 5adcdf3d..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateDatasetTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreateDatasetTest { - - @Test - fun createCreateDataset() { - val createDataset = - CreateDataset.builder() - .name("name") - .description("description") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(createDataset).isNotNull - assertThat(createDataset.name()).isEqualTo("name") - assertThat(createDataset.description()).isEqualTo("description") - assertThat(createDataset.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateExperimentTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateExperimentTest.kt deleted file mode 100755 index e549306e..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateExperimentTest.kt +++ /dev/null @@ -1,63 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreateExperimentTest { - - @Test - fun createCreateExperiment() { - val createExperiment = - CreateExperiment.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(CreateExperiment.Metadata.builder().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() - assertThat(createExperiment).isNotNull - assertThat(createExperiment.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createExperiment.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createExperiment.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createExperiment.datasetVersion()).isEqualTo("dataset_version") - assertThat(createExperiment.description()).isEqualTo("description") - assertThat(createExperiment.ensureNew()).isEqualTo(true) - assertThat(createExperiment.metadata()) - .isEqualTo(CreateExperiment.Metadata.builder().build()) - assertThat(createExperiment.name()).isEqualTo("name") - assertThat(createExperiment.public_()).isEqualTo(true) - assertThat(createExperiment.repoInfo()) - .isEqualTo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateFunctionTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateFunctionTest.kt deleted file mode 100755 index 7b3f9fdd..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateFunctionTest.kt +++ /dev/null @@ -1,183 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreateFunctionTest { - - @Test - fun createCreateFunction() { - val createFunction = - CreateFunction.builder() - .functionData( - CreateFunction.FunctionData.ofPrompt( - CreateFunction.FunctionData.Prompt.builder() - .type(CreateFunction.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(createFunction).isNotNull - assertThat(createFunction.functionData()) - .isEqualTo( - CreateFunction.FunctionData.ofPrompt( - CreateFunction.FunctionData.Prompt.builder() - .type(CreateFunction.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(createFunction.name()).isEqualTo("name") - assertThat(createFunction.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createFunction.slug()).isEqualTo("slug") - assertThat(createFunction.description()).isEqualTo("description") - assertThat(createFunction.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(createFunction.tags()).containsExactly("string") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateGroupTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateGroupTest.kt deleted file mode 100755 index dae4e041..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateGroupTest.kt +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreateGroupTest { - - @Test - fun createCreateGroup() { - val createGroup = - CreateGroup.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - assertThat(createGroup).isNotNull - assertThat(createGroup.name()).isEqualTo("name") - assertThat(createGroup.description()).isEqualTo("description") - assertThat(createGroup.memberGroups()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createGroup.memberUsers()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createGroup.orgName()).isEqualTo("org_name") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectScoreTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectScoreTest.kt deleted file mode 100755 index 9c8681b7..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectScoreTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreateProjectScoreTest { - - @Test - fun createCreateProjectScore() { - val createProjectScore = - CreateProjectScore.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(CreateProjectScore.ScoreType.SLIDER) - .categories( - CreateProjectScore.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .build() - assertThat(createProjectScore).isNotNull - assertThat(createProjectScore.name()).isEqualTo("name") - assertThat(createProjectScore.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createProjectScore.scoreType()).isEqualTo(CreateProjectScore.ScoreType.SLIDER) - assertThat(createProjectScore.categories()) - .isEqualTo( - CreateProjectScore.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - assertThat(createProjectScore.description()).isEqualTo("description") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTagTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTagTest.kt deleted file mode 100755 index d6db12e2..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTagTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreateProjectTagTest { - - @Test - fun createCreateProjectTag() { - val createProjectTag = - CreateProjectTag.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - assertThat(createProjectTag).isNotNull - assertThat(createProjectTag.name()).isEqualTo("name") - assertThat(createProjectTag.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createProjectTag.color()).isEqualTo("color") - assertThat(createProjectTag.description()).isEqualTo("description") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTest.kt deleted file mode 100755 index 16537333..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateProjectTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreateProjectTest { - - @Test - fun createCreateProject() { - val createProject = CreateProject.builder().name("name").orgName("org_name").build() - assertThat(createProject).isNotNull - assertThat(createProject.name()).isEqualTo("name") - assertThat(createProject.orgName()).isEqualTo("org_name") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreatePromptTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreatePromptTest.kt deleted file mode 100755 index c55fe28b..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreatePromptTest.kt +++ /dev/null @@ -1,168 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreatePromptTest { - - @Test - fun createCreatePrompt() { - val createPrompt = - CreatePrompt.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(createPrompt).isNotNull - assertThat(createPrompt.name()).isEqualTo("name") - assertThat(createPrompt.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createPrompt.slug()).isEqualTo("slug") - assertThat(createPrompt.description()).isEqualTo("description") - assertThat(createPrompt.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(createPrompt.tags()).containsExactly("string") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateRoleTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateRoleTest.kt deleted file mode 100755 index a35b27ff..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateRoleTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreateRoleTest { - - @Test - fun createCreateRole() { - val createRole = - CreateRole.builder() - .name("name") - .description("description") - .memberPermissions( - listOf( - CreateRole.MemberPermission.builder() - .permission(CreateRole.MemberPermission.Permission.CREATE) - .restrictObjectType( - CreateRole.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - assertThat(createRole).isNotNull - assertThat(createRole.name()).isEqualTo("name") - assertThat(createRole.description()).isEqualTo("description") - assertThat(createRole.memberPermissions()) - .containsExactly( - CreateRole.MemberPermission.builder() - .permission(CreateRole.MemberPermission.Permission.CREATE) - .restrictObjectType(CreateRole.MemberPermission.RestrictObjectType.ORGANIZATION) - .build() - ) - assertThat(createRole.memberRoles()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createRole.orgName()).isEqualTo("org_name") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateViewTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateViewTest.kt deleted file mode 100755 index b963ad9c..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CreateViewTest.kt +++ /dev/null @@ -1,72 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CreateViewTest { - - @Test - fun createCreateView() { - val createView = - CreateView.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(CreateView.ObjectType.ORGANIZATION) - .viewType(CreateView.ViewType.PROJECTS) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .options( - ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - .build() - assertThat(createView).isNotNull - assertThat(createView.name()).isEqualTo("name") - assertThat(createView.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createView.objectType()).isEqualTo(CreateView.ObjectType.ORGANIZATION) - assertThat(createView.viewType()).isEqualTo(CreateView.ViewType.PROJECTS) - assertThat(createView.deletedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(createView.options()) - .isEqualTo( - ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - assertThat(createView.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(createView.viewData()) - .isEqualTo( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequestTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequestTest.kt deleted file mode 100755 index 65891d5f..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertRequestTest.kt +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CrossObjectInsertRequestTest { - - @Test - fun createCrossObjectInsertRequest() { - val crossObjectInsertRequest = - CrossObjectInsertRequest.builder() - .dataset(CrossObjectInsertRequest.Dataset.builder().build()) - .experiment(CrossObjectInsertRequest.Experiment.builder().build()) - .projectLogs(CrossObjectInsertRequest.ProjectLogs.builder().build()) - .build() - assertThat(crossObjectInsertRequest).isNotNull - assertThat(crossObjectInsertRequest.dataset()) - .isEqualTo(CrossObjectInsertRequest.Dataset.builder().build()) - assertThat(crossObjectInsertRequest.experiment()) - .isEqualTo(CrossObjectInsertRequest.Experiment.builder().build()) - assertThat(crossObjectInsertRequest.projectLogs()) - .isEqualTo(CrossObjectInsertRequest.ProjectLogs.builder().build()) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt index 81efff33..afd5a503 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/CrossObjectInsertResponseTest.kt @@ -2,25 +2,29 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.CrossObjectInsertResponse class CrossObjectInsertResponseTest { @Test fun createCrossObjectInsertResponse() { - val crossObjectInsertResponse = - CrossObjectInsertResponse.builder() - .dataset(CrossObjectInsertResponse.Dataset.builder().build()) - .experiment(CrossObjectInsertResponse.Experiment.builder().build()) - .projectLogs(CrossObjectInsertResponse.ProjectLogs.builder().build()) - .build() - assertThat(crossObjectInsertResponse).isNotNull - assertThat(crossObjectInsertResponse.dataset()) - .isEqualTo(CrossObjectInsertResponse.Dataset.builder().build()) - assertThat(crossObjectInsertResponse.experiment()) - .isEqualTo(CrossObjectInsertResponse.Experiment.builder().build()) - assertThat(crossObjectInsertResponse.projectLogs()) - .isEqualTo(CrossObjectInsertResponse.ProjectLogs.builder().build()) + val crossObjectInsertResponse = CrossObjectInsertResponse.builder() + .dataset(CrossObjectInsertResponse.Dataset.builder().build()) + .experiment(CrossObjectInsertResponse.Experiment.builder().build()) + .projectLogs(CrossObjectInsertResponse.ProjectLogs.builder().build()) + .build() + assertThat(crossObjectInsertResponse).isNotNull + assertThat(crossObjectInsertResponse.dataset()).isEqualTo(CrossObjectInsertResponse.Dataset.builder().build()) + assertThat(crossObjectInsertResponse.experiment()).isEqualTo(CrossObjectInsertResponse.Experiment.builder().build()) + assertThat(crossObjectInsertResponse.projectLogs()).isEqualTo(CrossObjectInsertResponse.ProjectLogs.builder().build()) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt index 544c8f05..72b4f1c5 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DataSummaryTest.kt @@ -2,15 +2,25 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.DataSummary class DataSummaryTest { @Test fun createDataSummary() { - val dataSummary = DataSummary.builder().totalRecords(123L).build() - assertThat(dataSummary).isNotNull - assertThat(dataSummary.totalRecords()).isEqualTo(123L) + val dataSummary = DataSummary.builder() + .totalRecords(123L) + .build() + assertThat(dataSummary).isNotNull + assertThat(dataSummary.totalRecords()).isEqualTo(123L) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt index 1c64aaa5..5cf91a87 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetCreateParamsTest.kt @@ -2,41 +2,54 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.DatasetCreateParams +import com.braintrustdata.api.models.DatasetCreateParams.DatasetCreateBody class DatasetCreateParamsTest { @Test fun createDatasetCreateParams() { - DatasetCreateParams.builder() - .name("name") - .description("description") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + DatasetCreateParams.builder() + .name("name") + .description("description") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getBody() { - val params = - DatasetCreateParams.builder() - .name("name") - .description("description") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).isEqualTo("description") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = DatasetCreateParams.builder() + .name("name") + .description("description") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).isEqualTo("description") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun getBodyWithoutOptionalFields() { - val params = DatasetCreateParams.builder().name("name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = DatasetCreateParams.builder() + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt index bb209233..513b781c 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetDeleteParamsTest.kt @@ -2,25 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.DatasetDeleteParams class DatasetDeleteParamsTest { @Test fun createDatasetDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt index 542387b2..add55bf7 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetEventTest.kt @@ -2,41 +2,45 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.DatasetEvent 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") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(DatasetEvent.Metadata.builder().build()) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tags(listOf("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.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.metadata()).isEqualTo(DatasetEvent.Metadata.builder().build()) - assertThat(datasetEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(datasetEvent.tags()).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") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(DatasetEvent.Metadata.builder().build()) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tags(listOf("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.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.metadata()).isEqualTo(DatasetEvent.Metadata.builder().build()) + assertThat(datasetEvent.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(datasetEvent.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt index e5ec92fd..22c8f193 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFeedbackParamsTest.kt @@ -2,84 +2,85 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.DatasetFeedbackParams +import com.braintrustdata.api.models.DatasetFeedbackParams.DatasetFeedbackBody class DatasetFeedbackParamsTest { @Test fun createDatasetFeedbackParams() { - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) - .source(FeedbackDatasetItem.Source.APP) - .build() - ) - ) - .build() + DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) + .build())) + .build() } @Test fun getBody() { - val params = - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) - .source(FeedbackDatasetItem.Source.APP) - .build() - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()) - .isEqualTo( - listOf( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) - .source(FeedbackDatasetItem.Source.APP) - .build() - ) - ) + val params = DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) + .build())) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()).isEqualTo(listOf(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) + .build())) } @Test fun getBodyWithoutOptionalFields() { - val params = - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(FeedbackDatasetItem.builder().id("id").build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()) - .isEqualTo(listOf(FeedbackDatasetItem.builder().id("id").build())) + val params = DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackDatasetItem.builder() + .id("id") + .build())) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()).isEqualTo(listOf(FeedbackDatasetItem.builder() + .id("id") + .build())) } @Test fun getPathParam() { - val params = - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(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") + .feedback(listOf(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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt index 260bb3bb..6be62e7e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchParamsTest.kt @@ -2,57 +2,69 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.DatasetFetchParams class DatasetFetchParamsTest { @Test fun createDatasetFetchParams() { - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getQueryParams() { - val params = - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = mutableMapOf>() - expected.put("limit", listOf("123")) - expected.put("max_root_span_id", listOf("max_root_span_id")) - expected.put("max_xact_id", listOf("max_xact_id")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = mutableMapOf>() + expected.put("limit", listOf("123")) + expected.put("max_root_span_id", listOf("max_root_span_id")) + expected.put("max_xact_id", listOf("max_xact_id")) + expected.put("version", listOf("version")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = - DatasetFetchParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt index b43e0a1b..9628e81a 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostParamsTest.kt @@ -2,93 +2,88 @@ package com.braintrustdata.api.models +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID +import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test +import com.braintrustdata.api.models.DatasetFetchPostParams +import com.braintrustdata.api.models.DatasetFetchPostParams.DatasetFetchPostBody class DatasetFetchPostParamsTest { @Test fun createDatasetFetchPostParams() { - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getBody() { - val params = - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()) - .isEqualTo( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - assertThat(body.limit()).isEqualTo(123L) - assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") - assertThat(body.maxXactId()).isEqualTo("max_xact_id") - assertThat(body.version()).isEqualTo("version") + val params = DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.cursor()).isEqualTo("cursor") + assertThat(body.filters()).isEqualTo(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + assertThat(body.limit()).isEqualTo(123L) + assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") + assertThat(body.maxXactId()).isEqualTo("max_xact_id") + assertThat(body.version()).isEqualTo("version") } @Test fun getBodyWithoutOptionalFields() { - val params = - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponseTest.kt deleted file mode 100755 index be065f43..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchPostResponseTest.kt +++ /dev/null @@ -1,54 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class DatasetFetchPostResponseTest { - - @Test - fun createDatasetFetchPostResponse() { - val datasetFetchPostResponse = - DatasetFetchPostResponse.builder() - .events( - listOf( - DatasetFetchPostResponse.Event.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(DatasetFetchPostResponse.Event.Metadata.builder().build()) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tags(listOf("string")) - .build() - ) - ) - .cursor("cursor") - .build() - assertThat(datasetFetchPostResponse).isNotNull - assertThat(datasetFetchPostResponse.events()) - .containsExactly( - DatasetFetchPostResponse.Event.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(DatasetFetchPostResponse.Event.Metadata.builder().build()) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tags(listOf("string")) - .build() - ) - assertThat(datasetFetchPostResponse.cursor()).isEqualTo("cursor") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchResponseTest.kt deleted file mode 100755 index 09fa12cd..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetFetchResponseTest.kt +++ /dev/null @@ -1,54 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class DatasetFetchResponseTest { - - @Test - fun createDatasetFetchResponse() { - val datasetFetchResponse = - DatasetFetchResponse.builder() - .events( - listOf( - DatasetFetchResponse.Event.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(DatasetFetchResponse.Event.Metadata.builder().build()) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tags(listOf("string")) - .build() - ) - ) - .cursor("cursor") - .build() - assertThat(datasetFetchResponse).isNotNull - assertThat(datasetFetchResponse.events()) - .containsExactly( - DatasetFetchResponse.Event.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(DatasetFetchResponse.Event.Metadata.builder().build()) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tags(listOf("string")) - .build() - ) - assertThat(datasetFetchResponse.cursor()).isEqualTo("cursor") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt index 3aaeb8c0..e5fceedc 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertParamsTest.kt @@ -2,125 +2,94 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.models.* +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.DatasetInsertParams +import com.braintrustdata.api.models.DatasetInsertParams.DatasetInsertBody class DatasetInsertParamsTest { @Test fun createDatasetInsertParams() { - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() + DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) + .tags(listOf("string")) + .build()))) + .build() } @Test fun getBody() { - val params = - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - ) - ) - ) + val params = DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) + .tags(listOf("string")) + .build()))) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()).isEqualTo(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) + .tags(listOf("string")) + .build()))) } @Test fun getBodyWithoutOptionalFields() { - val params = - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder().build() - ) - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder().build() - ) - ) - ) + val params = DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(InsertDatasetEventReplace.builder().build()))) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()).isEqualTo(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(InsertDatasetEventReplace.builder().build()))) } @Test fun getPathParam() { - val params = - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.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") + .events(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(InsertDatasetEventReplace.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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertResponseTest.kt deleted file mode 100755 index a65d0c2f..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetInsertResponseTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class DatasetInsertResponseTest { - - @Test - fun createDatasetInsertResponse() { - val datasetInsertResponse = DatasetInsertResponse.builder().rowIds(listOf("string")).build() - assertThat(datasetInsertResponse).isNotNull - assertThat(datasetInsertResponse.rowIds()).containsExactly("string") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt index d0963d5e..edcc555b 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetListParamsTest.kt @@ -2,60 +2,65 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.DatasetListParams class DatasetListParamsTest { @Test fun createDatasetListParams() { - DatasetListParams.builder() - .datasetName("dataset_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .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(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - DatasetListParams.builder() - .datasetName("dataset_name") - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("dataset_name", listOf("dataset_name")) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf( - DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = DatasetListParams.builder() + .datasetName("dataset_name") + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("dataset_name", listOf("dataset_name")) + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(DatasetListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("project_name", listOf("project_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = DatasetListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = DatasetListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt index 776cce3b..f9495400 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetRetrieveParamsTest.kt @@ -2,27 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.DatasetRetrieveParams class DatasetRetrieveParamsTest { @Test fun createDatasetRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt index db5cbef2..6bc204d2 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeParamsTest.kt @@ -2,52 +2,60 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.DatasetSummarizeParams class DatasetSummarizeParamsTest { @Test fun createDatasetSummarizeParams() { - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() + DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() } @Test fun getQueryParams() { - val params = - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() - val expected = mutableMapOf>() - expected.put("summarize_data", listOf("true")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build() + val expected = mutableMapOf>() + expected.put("summarize_data", listOf("true")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponseTest.kt deleted file mode 100755 index a9521efa..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetSummarizeResponseTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class DatasetSummarizeResponseTest { - - @Test - fun createDatasetSummarizeResponse() { - val datasetSummarizeResponse = - DatasetSummarizeResponse.builder() - .datasetName("dataset_name") - .datasetUrl("https://example.com") - .projectName("project_name") - .projectUrl("https://example.com") - .dataSummary( - DatasetSummarizeResponse.DataSummary.builder().totalRecords(123L).build() - ) - .build() - assertThat(datasetSummarizeResponse).isNotNull - assertThat(datasetSummarizeResponse.datasetName()).isEqualTo("dataset_name") - assertThat(datasetSummarizeResponse.datasetUrl()).isEqualTo("https://example.com") - assertThat(datasetSummarizeResponse.projectName()).isEqualTo("project_name") - assertThat(datasetSummarizeResponse.projectUrl()).isEqualTo("https://example.com") - assertThat(datasetSummarizeResponse.dataSummary()) - .isEqualTo(DatasetSummarizeResponse.DataSummary.builder().totalRecords(123L).build()) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt index 45fad879..bd30b24f 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetTest.kt @@ -2,33 +2,39 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.Dataset class DatasetTest { @Test fun createDataset() { - val dataset = - Dataset.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") - .metadata(Dataset.Metadata.builder().build()) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .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.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(dataset.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(dataset.description()).isEqualTo("description") - assertThat(dataset.metadata()).isEqualTo(Dataset.Metadata.builder().build()) - assertThat(dataset.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(dataset.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val dataset = Dataset.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") + .metadata(Dataset.Metadata.builder().build()) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .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.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(dataset.description()).isEqualTo("description") + assertThat(dataset.metadata()).isEqualTo(Dataset.Metadata.builder().build()) + assertThat(dataset.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(dataset.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt index e8dfdbe0..4754f3e1 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DatasetUpdateParamsTest.kt @@ -2,54 +2,67 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.DatasetUpdateParams +import com.braintrustdata.api.models.DatasetUpdateParams.DatasetUpdateBody class DatasetUpdateParamsTest { @Test fun createDatasetUpdateParams() { - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetUpdateParams.Metadata.builder().build()) - .name("name") - .build() + DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder().build()) + .name("name") + .build() } @Test fun getBody() { - val params = - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetUpdateParams.Metadata.builder().build()) - .name("name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.description()).isEqualTo("description") - assertThat(body.metadata()).isEqualTo(DatasetUpdateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") + val params = DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder().build()) + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.description()).isEqualTo("description") + assertThat(body.metadata()).isEqualTo(DatasetUpdateParams.Metadata.builder().build()) + assertThat(body.name()).isEqualTo("name") } @Test fun getBodyWithoutOptionalFields() { - val params = - DatasetUpdateParams.builder().datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() - assertThat(body).isNotNull + val params = DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DeleteViewTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DeleteViewTest.kt deleted file mode 100755 index 0b9a3f3c..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/DeleteViewTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class DeleteViewTest { - - @Test - fun createDeleteView() { - val deleteView = - DeleteView.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(DeleteView.ObjectType.ORGANIZATION) - .build() - assertThat(deleteView).isNotNull - assertThat(deleteView.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(deleteView.objectType()).isEqualTo(DeleteView.ObjectType.ORGANIZATION) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt index 35e96747..2c2205be 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentCreateParamsTest.kt @@ -2,102 +2,105 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ExperimentCreateParams +import com.braintrustdata.api.models.ExperimentCreateParams.ExperimentCreateBody class ExperimentCreateParamsTest { @Test fun createExperimentCreateParams() { - 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().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() + 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().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 getBody() { - 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().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.getBody() - assertThat(body).isNotNull - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).isEqualTo("dataset_version") - assertThat(body.description()).isEqualTo("description") - assertThat(body.ensureNew()).isEqualTo(true) - assertThat(body.metadata()).isEqualTo(ExperimentCreateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") - assertThat(body.public_()).isEqualTo(true) - assertThat(body.repoInfo()) - .isEqualTo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) + 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().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.getBody() + assertThat(body).isNotNull + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).isEqualTo("dataset_version") + assertThat(body.description()).isEqualTo("description") + assertThat(body.ensureNew()).isEqualTo(true) + assertThat(body.metadata()).isEqualTo(ExperimentCreateParams.Metadata.builder().build()) + assertThat(body.name()).isEqualTo("name") + assertThat(body.public_()).isEqualTo(true) + assertThat(body.repoInfo()).isEqualTo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) } @Test fun getBodyWithoutOptionalFields() { - val params = - ExperimentCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = ExperimentCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt index 4577db52..3168b8d0 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentDeleteParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ExperimentDeleteParams class ExperimentDeleteParamsTest { @Test fun createExperimentDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt index 93ac67b9..953587c5 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentEventTest.kt @@ -2,98 +2,87 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ExperimentEvent 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(123L) - .build() - ) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ExperimentEvent.Metadata.builder().build()) - .metrics( - ExperimentEvent.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ExperimentEvent.Scores.builder().build()) - .spanAttributes( - ExperimentEvent.SpanAttributes.builder() - .name("name") - .type(ExperimentEvent.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("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()) - .isEqualTo( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - assertThat(experimentEvent.datasetRecordId()).isEqualTo("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.metadata()).isEqualTo(ExperimentEvent.Metadata.builder().build()) - assertThat(experimentEvent.metrics()) - .isEqualTo( - ExperimentEvent.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(experimentEvent.scores()).isEqualTo(ExperimentEvent.Scores.builder().build()) - assertThat(experimentEvent.spanAttributes()) - .isEqualTo( - ExperimentEvent.SpanAttributes.builder() - .name("name") - .type(ExperimentEvent.SpanAttributes.Type.LLM) - .build() - ) - assertThat(experimentEvent.spanParents()).containsExactly("string") - assertThat(experimentEvent.tags()).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(123L) + .build()) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ExperimentEvent.Metadata.builder().build()) + .metrics(ExperimentEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder().build()) + .spanAttributes(ExperimentEvent.SpanAttributes.builder() + .name("name") + .type(ExperimentEvent.SpanAttributes.Type.LLM) + .build()) + .spanParents(listOf("string")) + .tags(listOf("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()).isEqualTo(ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + assertThat(experimentEvent.datasetRecordId()).isEqualTo("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.metadata()).isEqualTo(ExperimentEvent.Metadata.builder().build()) + assertThat(experimentEvent.metrics()).isEqualTo(ExperimentEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + assertThat(experimentEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(experimentEvent.scores()).isEqualTo(ExperimentEvent.Scores.builder().build()) + assertThat(experimentEvent.spanAttributes()).isEqualTo(ExperimentEvent.SpanAttributes.builder() + .name("name") + .type(ExperimentEvent.SpanAttributes.Type.LLM) + .build()) + assertThat(experimentEvent.spanParents()).containsExactly("string") + assertThat(experimentEvent.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt index 59d68ce1..dd01fcb8 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFeedbackParamsTest.kt @@ -2,91 +2,91 @@ package com.braintrustdata.api.models +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID +import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test +import com.braintrustdata.api.models.ExperimentFeedbackParams +import com.braintrustdata.api.models.ExperimentFeedbackParams.ExperimentFeedbackBody class ExperimentFeedbackParamsTest { @Test fun createExperimentFeedbackParams() { - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) - .source(FeedbackExperimentItem.Source.APP) - .build() - ) - ) - .build() + ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) + .build())) + .build() } @Test fun getBody() { - val params = - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) - .source(FeedbackExperimentItem.Source.APP) - .build() - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()) - .isEqualTo( - listOf( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) - .source(FeedbackExperimentItem.Source.APP) - .build() - ) - ) + val params = ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) + .build())) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()).isEqualTo(listOf(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) + .build())) } @Test fun getBodyWithoutOptionalFields() { - val params = - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(FeedbackExperimentItem.builder().id("id").build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()) - .isEqualTo(listOf(FeedbackExperimentItem.builder().id("id").build())) + val params = ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackExperimentItem.builder() + .id("id") + .build())) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()).isEqualTo(listOf(FeedbackExperimentItem.builder() + .id("id") + .build())) } @Test fun getPathParam() { - val params = - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(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") + .feedback(listOf(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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt index 138cbb6a..7df38c26 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchParamsTest.kt @@ -2,61 +2,69 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ExperimentFetchParams class ExperimentFetchParamsTest { @Test fun createExperimentFetchParams() { - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getQueryParams() { - val params = - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = mutableMapOf>() - expected.put("limit", listOf("123")) - expected.put("max_root_span_id", listOf("max_root_span_id")) - expected.put("max_xact_id", listOf("max_xact_id")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = mutableMapOf>() + expected.put("limit", listOf("123")) + expected.put("max_root_span_id", listOf("max_root_span_id")) + expected.put("max_xact_id", listOf("max_xact_id")) + expected.put("version", listOf("version")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt index 45a9cd0b..c22732d8 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostParamsTest.kt @@ -2,93 +2,88 @@ package com.braintrustdata.api.models +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID +import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test +import com.braintrustdata.api.models.ExperimentFetchPostParams +import com.braintrustdata.api.models.ExperimentFetchPostParams.ExperimentFetchPostBody class ExperimentFetchPostParamsTest { @Test fun createExperimentFetchPostParams() { - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getBody() { - val params = - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()) - .isEqualTo( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - assertThat(body.limit()).isEqualTo(123L) - assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") - assertThat(body.maxXactId()).isEqualTo("max_xact_id") - assertThat(body.version()).isEqualTo("version") + val params = ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.cursor()).isEqualTo("cursor") + assertThat(body.filters()).isEqualTo(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + assertThat(body.limit()).isEqualTo(123L) + assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") + assertThat(body.maxXactId()).isEqualTo("max_xact_id") + assertThat(body.version()).isEqualTo("version") } @Test fun getBodyWithoutOptionalFields() { - val params = - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponseTest.kt deleted file mode 100755 index 40a4d148..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchPostResponseTest.kt +++ /dev/null @@ -1,106 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ExperimentFetchPostResponseTest { - - @Test - fun createExperimentFetchPostResponse() { - val experimentFetchPostResponse = - ExperimentFetchPostResponse.builder() - .events( - listOf( - ExperimentFetchPostResponse.Event.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("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .context( - ExperimentFetchPostResponse.Event.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .datasetRecordId("dataset_record_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ExperimentFetchPostResponse.Event.Metadata.builder().build()) - .metrics( - ExperimentFetchPostResponse.Event.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ExperimentFetchPostResponse.Event.Scores.builder().build()) - .spanAttributes( - ExperimentFetchPostResponse.Event.SpanAttributes.builder() - .name("name") - .type(ExperimentFetchPostResponse.Event.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - ) - .cursor("cursor") - .build() - assertThat(experimentFetchPostResponse).isNotNull - assertThat(experimentFetchPostResponse.events()) - .containsExactly( - ExperimentFetchPostResponse.Event.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("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .context( - ExperimentFetchPostResponse.Event.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .datasetRecordId("dataset_record_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ExperimentFetchPostResponse.Event.Metadata.builder().build()) - .metrics( - ExperimentFetchPostResponse.Event.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ExperimentFetchPostResponse.Event.Scores.builder().build()) - .spanAttributes( - ExperimentFetchPostResponse.Event.SpanAttributes.builder() - .name("name") - .type(ExperimentFetchPostResponse.Event.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - assertThat(experimentFetchPostResponse.cursor()).isEqualTo("cursor") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchResponseTest.kt deleted file mode 100755 index e7f88c53..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentFetchResponseTest.kt +++ /dev/null @@ -1,106 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ExperimentFetchResponseTest { - - @Test - fun createExperimentFetchResponse() { - val experimentFetchResponse = - ExperimentFetchResponse.builder() - .events( - listOf( - ExperimentFetchResponse.Event.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("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .context( - ExperimentFetchResponse.Event.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .datasetRecordId("dataset_record_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ExperimentFetchResponse.Event.Metadata.builder().build()) - .metrics( - ExperimentFetchResponse.Event.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ExperimentFetchResponse.Event.Scores.builder().build()) - .spanAttributes( - ExperimentFetchResponse.Event.SpanAttributes.builder() - .name("name") - .type(ExperimentFetchResponse.Event.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - ) - .cursor("cursor") - .build() - assertThat(experimentFetchResponse).isNotNull - assertThat(experimentFetchResponse.events()) - .containsExactly( - ExperimentFetchResponse.Event.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("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .context( - ExperimentFetchResponse.Event.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .datasetRecordId("dataset_record_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ExperimentFetchResponse.Event.Metadata.builder().build()) - .metrics( - ExperimentFetchResponse.Event.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ExperimentFetchResponse.Event.Scores.builder().build()) - .spanAttributes( - ExperimentFetchResponse.Event.SpanAttributes.builder() - .name("name") - .type(ExperimentFetchResponse.Event.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - assertThat(experimentFetchResponse.cursor()).isEqualTo("cursor") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt index d5e9c1c9..4a8b7c5f 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertParamsTest.kt @@ -2,203 +2,154 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.models.* +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ExperimentInsertParams +import com.braintrustdata.api.models.ExperimentInsertParams.ExperimentInsertBody class ExperimentInsertParamsTest { @Test fun createExperimentInsertParams() { - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEventReplace.Metadata.builder().build()) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() + ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) + .metrics(InsertExperimentEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertExperimentEventReplace.Scores.builder().build()) + .spanAttributes(InsertExperimentEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build()))) + .build() } @Test fun getBody() { - val params = - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEventReplace.Metadata.builder().build()) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEventReplace.Metadata.builder().build()) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) + val params = ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) + .metrics(InsertExperimentEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertExperimentEventReplace.Scores.builder().build()) + .spanAttributes(InsertExperimentEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build()))) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()).isEqualTo(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) + .metrics(InsertExperimentEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertExperimentEventReplace.Scores.builder().build()) + .spanAttributes(InsertExperimentEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build()))) } @Test fun getBodyWithoutOptionalFields() { - val params = - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder().build() - ) - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder().build() - ) - ) - ) + val params = ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(InsertExperimentEventReplace.builder().build()))) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()).isEqualTo(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(InsertExperimentEventReplace.builder().build()))) } @Test fun getPathParam() { - val params = - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.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") + .events(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(InsertExperimentEventReplace.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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertResponseTest.kt deleted file mode 100755 index 382e1f24..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentInsertResponseTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ExperimentInsertResponseTest { - - @Test - fun createExperimentInsertResponse() { - val experimentInsertResponse = - ExperimentInsertResponse.builder().rowIds(listOf("string")).build() - assertThat(experimentInsertResponse).isNotNull - assertThat(experimentInsertResponse.rowIds()).containsExactly("string") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt index 2168e880..44af8b0a 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentListParamsTest.kt @@ -2,60 +2,65 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ExperimentListParams class ExperimentListParamsTest { @Test fun createExperimentListParams() { - ExperimentListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .experimentName("experiment_name") - .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .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(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - ExperimentListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .experimentName("experiment_name") - .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("experiment_name", listOf("experiment_name")) - expected.put( - "ids", - listOf( - ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ExperimentListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .experimentName("experiment_name") + .ids(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("experiment_name", listOf("experiment_name")) + expected.put("ids", listOf(ExperimentListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("project_name", listOf("project_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = ExperimentListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ExperimentListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt index 5efe0624..ae100b9e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentRetrieveParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ExperimentRetrieveParams class ExperimentRetrieveParamsTest { @Test fun createExperimentRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt index d813806c..748691b4 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeParamsTest.kt @@ -2,55 +2,63 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ExperimentSummarizeParams class ExperimentSummarizeParamsTest { @Test fun createExperimentSummarizeParams() { - 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 getQueryParams() { - val params = - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() - val expected = mutableMapOf>() - expected.put("comparison_experiment_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("summarize_scores", listOf("true")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build() + val expected = mutableMapOf>() + expected.put("comparison_experiment_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("summarize_scores", listOf("true")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponseTest.kt deleted file mode 100755 index a0016a05..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentSummarizeResponseTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ExperimentSummarizeResponseTest { - - @Test - fun createExperimentSummarizeResponse() { - val experimentSummarizeResponse = - ExperimentSummarizeResponse.builder() - .experimentName("experiment_name") - .experimentUrl("https://example.com") - .projectName("project_name") - .projectUrl("https://example.com") - .comparisonExperimentName("comparison_experiment_name") - .metrics(ExperimentSummarizeResponse.Metrics.builder().build()) - .scores(ExperimentSummarizeResponse.Scores.builder().build()) - .build() - assertThat(experimentSummarizeResponse).isNotNull - assertThat(experimentSummarizeResponse.experimentName()).isEqualTo("experiment_name") - assertThat(experimentSummarizeResponse.experimentUrl()).isEqualTo("https://example.com") - assertThat(experimentSummarizeResponse.projectName()).isEqualTo("project_name") - assertThat(experimentSummarizeResponse.projectUrl()).isEqualTo("https://example.com") - assertThat(experimentSummarizeResponse.comparisonExperimentName()) - .isEqualTo("comparison_experiment_name") - assertThat(experimentSummarizeResponse.metrics()) - .isEqualTo(ExperimentSummarizeResponse.Metrics.builder().build()) - assertThat(experimentSummarizeResponse.scores()) - .isEqualTo(ExperimentSummarizeResponse.Scores.builder().build()) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt index 430f4803..60a35b30 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentTest.kt @@ -2,71 +2,71 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.Experiment 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().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()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.commit()).isEqualTo("commit") - assertThat(experiment.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experiment.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(experiment.datasetVersion()).isEqualTo("dataset_version") - assertThat(experiment.deletedAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(experiment.description()).isEqualTo("description") - assertThat(experiment.metadata()).isEqualTo(Experiment.Metadata.builder().build()) - assertThat(experiment.repoInfo()) - .isEqualTo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - assertThat(experiment.userId()).isEqualTo("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().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()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.commit()).isEqualTo("commit") + assertThat(experiment.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experiment.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(experiment.datasetVersion()).isEqualTo("dataset_version") + assertThat(experiment.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(experiment.description()).isEqualTo("description") + assertThat(experiment.metadata()).isEqualTo(Experiment.Metadata.builder().build()) + assertThat(experiment.repoInfo()).isEqualTo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) + assertThat(experiment.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt index 22231f89..2a221dc5 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ExperimentUpdateParamsTest.kt @@ -2,110 +2,112 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ExperimentUpdateParams +import com.braintrustdata.api.models.ExperimentUpdateParams.ExperimentUpdateBody class ExperimentUpdateParamsTest { @Test fun createExperimentUpdateParams() { - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata(ExperimentUpdateParams.Metadata.builder().build()) - .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().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 getBody() { - 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().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.getBody() - assertThat(body).isNotNull - assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.datasetVersion()).isEqualTo("dataset_version") - assertThat(body.description()).isEqualTo("description") - assertThat(body.metadata()).isEqualTo(ExperimentUpdateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") - assertThat(body.public_()).isEqualTo(true) - assertThat(body.repoInfo()) - .isEqualTo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) + 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().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.getBody() + assertThat(body).isNotNull + assertThat(body.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.datasetVersion()).isEqualTo("dataset_version") + assertThat(body.description()).isEqualTo("description") + assertThat(body.metadata()).isEqualTo(ExperimentUpdateParams.Metadata.builder().build()) + assertThat(body.name()).isEqualTo("name") + assertThat(body.public_()).isEqualTo(true) + assertThat(body.repoInfo()).isEqualTo(RepoInfo.builder() + .authorEmail("author_email") + .authorName("author_name") + .branch("branch") + .commit("commit") + .commitMessage("commit_message") + .commitTime("commit_time") + .dirty(true) + .gitDiff("git_diff") + .tag("tag") + .build()) } @Test fun getBodyWithoutOptionalFields() { - val params = - ExperimentUpdateParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = ExperimentUpdateParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequestTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequestTest.kt deleted file mode 100755 index a98a49a2..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetEventRequestTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class FeedbackDatasetEventRequestTest { - - @Test - fun createFeedbackDatasetEventRequest() { - val feedbackDatasetEventRequest = - FeedbackDatasetEventRequest.builder() - .feedback( - listOf( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) - .source(FeedbackDatasetItem.Source.APP) - .build() - ) - ) - .build() - assertThat(feedbackDatasetEventRequest).isNotNull - assertThat(feedbackDatasetEventRequest.feedback()) - .containsExactly( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) - .source(FeedbackDatasetItem.Source.APP) - .build() - ) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt index 75f6c727..f630f2bd 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackDatasetItemTest.kt @@ -2,25 +2,31 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.FeedbackDatasetItem class FeedbackDatasetItemTest { @Test fun createFeedbackDatasetItem() { - val feedbackDatasetItem = - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) - .source(FeedbackDatasetItem.Source.APP) - .build() - assertThat(feedbackDatasetItem).isNotNull - assertThat(feedbackDatasetItem.id()).isEqualTo("id") - assertThat(feedbackDatasetItem.comment()).isEqualTo("comment") - assertThat(feedbackDatasetItem.metadata()) - .isEqualTo(FeedbackDatasetItem.Metadata.builder().build()) - assertThat(feedbackDatasetItem.source()).isEqualTo(FeedbackDatasetItem.Source.APP) + val feedbackDatasetItem = FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) + .build() + assertThat(feedbackDatasetItem).isNotNull + assertThat(feedbackDatasetItem.id()).isEqualTo("id") + assertThat(feedbackDatasetItem.comment()).isEqualTo("comment") + assertThat(feedbackDatasetItem.metadata()).isEqualTo(FeedbackDatasetItem.Metadata.builder().build()) + assertThat(feedbackDatasetItem.source()).isEqualTo(FeedbackDatasetItem.Source.APP) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequestTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequestTest.kt deleted file mode 100755 index e94155cc..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentEventRequestTest.kt +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class FeedbackExperimentEventRequestTest { - - @Test - fun createFeedbackExperimentEventRequest() { - val feedbackExperimentEventRequest = - FeedbackExperimentEventRequest.builder() - .feedback( - listOf( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) - .source(FeedbackExperimentItem.Source.APP) - .build() - ) - ) - .build() - assertThat(feedbackExperimentEventRequest).isNotNull - assertThat(feedbackExperimentEventRequest.feedback()) - .containsExactly( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) - .source(FeedbackExperimentItem.Source.APP) - .build() - ) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt index a932afb8..480e8723 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackExperimentItemTest.kt @@ -2,32 +2,35 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.FeedbackExperimentItem class FeedbackExperimentItemTest { @Test fun createFeedbackExperimentItem() { - val feedbackExperimentItem = - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) - .source(FeedbackExperimentItem.Source.APP) - .build() - assertThat(feedbackExperimentItem).isNotNull - assertThat(feedbackExperimentItem.id()).isEqualTo("id") - assertThat(feedbackExperimentItem.comment()).isEqualTo("comment") - assertThat(feedbackExperimentItem._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(feedbackExperimentItem.metadata()) - .isEqualTo(FeedbackExperimentItem.Metadata.builder().build()) - assertThat(feedbackExperimentItem.scores()) - .isEqualTo(FeedbackExperimentItem.Scores.builder().build()) - assertThat(feedbackExperimentItem.source()).isEqualTo(FeedbackExperimentItem.Source.APP) + val feedbackExperimentItem = FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) + .build() + assertThat(feedbackExperimentItem).isNotNull + assertThat(feedbackExperimentItem.id()).isEqualTo("id") + assertThat(feedbackExperimentItem.comment()).isEqualTo("comment") + assertThat(feedbackExperimentItem._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackExperimentItem.metadata()).isEqualTo(FeedbackExperimentItem.Metadata.builder().build()) + assertThat(feedbackExperimentItem.scores()).isEqualTo(FeedbackExperimentItem.Scores.builder().build()) + assertThat(feedbackExperimentItem.source()).isEqualTo(FeedbackExperimentItem.Source.APP) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequestTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequestTest.kt deleted file mode 100755 index 78255f53..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsEventRequestTest.kt +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class FeedbackProjectLogsEventRequestTest { - - @Test - fun createFeedbackProjectLogsEventRequest() { - val feedbackProjectLogsEventRequest = - FeedbackProjectLogsEventRequest.builder() - .feedback( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .build() - ) - ) - .build() - assertThat(feedbackProjectLogsEventRequest).isNotNull - assertThat(feedbackProjectLogsEventRequest.feedback()) - .containsExactly( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .build() - ) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt index d26ef59b..e63a5042 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackProjectLogsItemTest.kt @@ -2,32 +2,35 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.FeedbackProjectLogsItem class FeedbackProjectLogsItemTest { @Test fun createFeedbackProjectLogsItem() { - val feedbackProjectLogsItem = - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .build() - assertThat(feedbackProjectLogsItem).isNotNull - assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") - assertThat(feedbackProjectLogsItem.comment()).isEqualTo("comment") - assertThat(feedbackProjectLogsItem._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(feedbackProjectLogsItem.metadata()) - .isEqualTo(FeedbackProjectLogsItem.Metadata.builder().build()) - assertThat(feedbackProjectLogsItem.scores()) - .isEqualTo(FeedbackProjectLogsItem.Scores.builder().build()) - assertThat(feedbackProjectLogsItem.source()).isEqualTo(FeedbackProjectLogsItem.Source.APP) + val feedbackProjectLogsItem = FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) + .build() + assertThat(feedbackProjectLogsItem).isNotNull + assertThat(feedbackProjectLogsItem.id()).isEqualTo("id") + assertThat(feedbackProjectLogsItem.comment()).isEqualTo("comment") + assertThat(feedbackProjectLogsItem._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(feedbackProjectLogsItem.metadata()).isEqualTo(FeedbackProjectLogsItem.Metadata.builder().build()) + assertThat(feedbackProjectLogsItem.scores()).isEqualTo(FeedbackProjectLogsItem.Scores.builder().build()) + assertThat(feedbackProjectLogsItem.source()).isEqualTo(FeedbackProjectLogsItem.Source.APP) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt index a1b62a0b..f0badcb3 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FeedbackResponseSchemaTest.kt @@ -2,16 +2,25 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.FeedbackResponseSchema 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt index a046233d..b6f00dc9 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchDatasetEventsResponseTest.kt @@ -2,53 +2,51 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.FetchDatasetEventsResponse class FetchDatasetEventsResponseTest { @Test fun createFetchDatasetEventsResponse() { - val fetchDatasetEventsResponse = - FetchDatasetEventsResponse.builder() - .events( - listOf( - DatasetEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(DatasetEvent.Metadata.builder().build()) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tags(listOf("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") - .rootSpanId("root_span_id") - .spanId("span_id") - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(DatasetEvent.Metadata.builder().build()) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .tags(listOf("string")) - .build() - ) - assertThat(fetchDatasetEventsResponse.cursor()).isEqualTo("cursor") + val fetchDatasetEventsResponse = FetchDatasetEventsResponse.builder() + .events(listOf(DatasetEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(DatasetEvent.Metadata.builder().build()) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tags(listOf("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") + .rootSpanId("root_span_id") + .spanId("span_id") + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(DatasetEvent.Metadata.builder().build()) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tags(listOf("string")) + .build()) + assertThat(fetchDatasetEventsResponse.cursor()).isEqualTo("cursor") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchEventsRequestTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchEventsRequestTest.kt deleted file mode 100755 index e8681833..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchEventsRequestTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class FetchEventsRequestTest { - - @Test - fun createFetchEventsRequest() { - val fetchEventsRequest = - FetchEventsRequest.builder() - .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - assertThat(fetchEventsRequest).isNotNull - assertThat(fetchEventsRequest.cursor()).isEqualTo("cursor") - assertThat(fetchEventsRequest.filters()) - .containsExactly( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - assertThat(fetchEventsRequest.limit()).isEqualTo(123L) - assertThat(fetchEventsRequest.maxRootSpanId()).isEqualTo("max_root_span_id") - assertThat(fetchEventsRequest.maxXactId()).isEqualTo("max_xact_id") - assertThat(fetchEventsRequest.version()).isEqualTo("version") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt index 3bb971ad..ba8a2707 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchExperimentEventsResponseTest.kt @@ -2,107 +2,93 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.FetchExperimentEventsResponse class FetchExperimentEventsResponseTest { @Test fun createFetchExperimentEventsResponse() { - val fetchExperimentEventsResponse = - FetchExperimentEventsResponse.builder() - .events( - listOf( - ExperimentEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ExperimentEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ExperimentEvent.Metadata.builder().build()) - .metrics( - ExperimentEvent.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ExperimentEvent.Scores.builder().build()) - .spanAttributes( - ExperimentEvent.SpanAttributes.builder() - .name("name") - .type(ExperimentEvent.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("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(123L) - .build() - ) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ExperimentEvent.Metadata.builder().build()) - .metrics( - ExperimentEvent.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ExperimentEvent.Scores.builder().build()) - .spanAttributes( - ExperimentEvent.SpanAttributes.builder() - .name("name") - .type(ExperimentEvent.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - assertThat(fetchExperimentEventsResponse.cursor()).isEqualTo("cursor") + val fetchExperimentEventsResponse = FetchExperimentEventsResponse.builder() + .events(listOf(ExperimentEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ExperimentEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ExperimentEvent.Metadata.builder().build()) + .metrics(ExperimentEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder().build()) + .spanAttributes(ExperimentEvent.SpanAttributes.builder() + .name("name") + .type(ExperimentEvent.SpanAttributes.Type.LLM) + .build()) + .spanParents(listOf("string")) + .tags(listOf("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(123L) + .build()) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ExperimentEvent.Metadata.builder().build()) + .metrics(ExperimentEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ExperimentEvent.Scores.builder().build()) + .spanAttributes(ExperimentEvent.SpanAttributes.builder() + .name("name") + .type(ExperimentEvent.SpanAttributes.Type.LLM) + .build()) + .spanParents(listOf("string")) + .tags(listOf("string")) + .build()) + assertThat(fetchExperimentEventsResponse.cursor()).isEqualTo("cursor") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt index 4c627827..e4e3c931 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FetchProjectLogsEventsResponseTest.kt @@ -2,107 +2,93 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.FetchProjectLogsEventsResponse class FetchProjectLogsEventsResponseTest { @Test fun createFetchProjectLogsEventsResponse() { - val fetchProjectLogsEventsResponse = - FetchProjectLogsEventsResponse.builder() - .events( - listOf( - ProjectLogsEvent.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogsEvent.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("root_span_id") - .spanId("span_id") - .context( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ProjectLogsEvent.Metadata.builder().build()) - .metrics( - ProjectLogsEvent.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogsEvent.Scores.builder().build()) - .spanAttributes( - ProjectLogsEvent.SpanAttributes.builder() - .name("name") - .type(ProjectLogsEvent.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("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(123L) - .build() - ) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ProjectLogsEvent.Metadata.builder().build()) - .metrics( - ProjectLogsEvent.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogsEvent.Scores.builder().build()) - .spanAttributes( - ProjectLogsEvent.SpanAttributes.builder() - .name("name") - .type(ProjectLogsEvent.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - assertThat(fetchProjectLogsEventsResponse.cursor()).isEqualTo("cursor") + val fetchProjectLogsEventsResponse = FetchProjectLogsEventsResponse.builder() + .events(listOf(ProjectLogsEvent.builder() + .id("id") + ._xactId("_xact_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .logId(ProjectLogsEvent.LogId.G) + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .rootSpanId("root_span_id") + .spanId("span_id") + .context(ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ProjectLogsEvent.Metadata.builder().build()) + .metrics(ProjectLogsEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder().build()) + .spanAttributes(ProjectLogsEvent.SpanAttributes.builder() + .name("name") + .type(ProjectLogsEvent.SpanAttributes.Type.LLM) + .build()) + .spanParents(listOf("string")) + .tags(listOf("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(123L) + .build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ProjectLogsEvent.Metadata.builder().build()) + .metrics(ProjectLogsEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder().build()) + .spanAttributes(ProjectLogsEvent.SpanAttributes.builder() + .name("name") + .type(ProjectLogsEvent.SpanAttributes.Type.LLM) + .build()) + .spanParents(listOf("string")) + .tags(listOf("string")) + .build()) + assertThat(fetchProjectLogsEventsResponse.cursor()).isEqualTo("cursor") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt index d5ab1485..4b73fb55 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionCreateParamsTest.kt @@ -2,347 +2,202 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.FunctionCreateParams +import com.braintrustdata.api.models.FunctionCreateParams.FunctionCreateBody class FunctionCreateParamsTest { @Test fun createFunctionCreateParams() { - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(FunctionCreateParams.FunctionType.TASK) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() + FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(FunctionCreateParams.FunctionType.TASK) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build() } @Test fun getBody() { - val params = - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(FunctionCreateParams.FunctionType.TASK) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.functionData()) - .isEqualTo( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") - assertThat(body.description()).isEqualTo("description") - assertThat(body.functionType()).isEqualTo(FunctionCreateParams.FunctionType.TASK) - assertThat(body.origin()) - .isEqualTo( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - assertThat(body.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(body.tags()).isEqualTo(listOf("string")) + val params = FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(FunctionCreateParams.FunctionType.TASK) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.functionData()).isEqualTo(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") + assertThat(body.description()).isEqualTo("description") + assertThat(body.functionType()).isEqualTo(FunctionCreateParams.FunctionType.TASK) + assertThat(body.origin()).isEqualTo(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + assertThat(body.promptData()).isEqualTo(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + assertThat(body.tags()).isEqualTo(listOf("string")) } @Test fun getBodyWithoutOptionalFields() { - val params = - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.functionData()) - .isEqualTo( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + val params = FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.functionData()).isEqualTo(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt index b6a1f5f2..053504e3 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionDeleteParamsTest.kt @@ -2,27 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.FunctionDeleteParams class FunctionDeleteParamsTest { @Test fun createFunctionDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt index 5e560da4..4ac1f07e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionListParamsTest.kt @@ -2,66 +2,71 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.FunctionListParams class FunctionListParamsTest { @Test fun createFunctionListParams() { - FunctionListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .functionName("function_name") - .ids(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .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(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .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 getQueryParams() { - val params = - FunctionListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .functionName("function_name") - .ids(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .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 = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("function_name", listOf("function_name")) - expected.put( - "ids", - listOf( - FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("slug", listOf("slug")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = FunctionListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .functionName("function_name") + .ids(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .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 = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("function_name", listOf("function_name")) + expected.put("ids", listOf(FunctionListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("project_name", listOf("project_name")) + expected.put("slug", listOf("slug")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("version", listOf("version")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = FunctionListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = FunctionListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt index 485142e5..e29292f6 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionReplaceParamsTest.kt @@ -2,347 +2,202 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.FunctionReplaceParams +import com.braintrustdata.api.models.FunctionReplaceParams.FunctionReplaceBody class FunctionReplaceParamsTest { @Test fun createFunctionReplaceParams() { - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(FunctionReplaceParams.FunctionType.TASK) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() + FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(FunctionReplaceParams.FunctionType.TASK) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build() } @Test fun getBody() { - val params = - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(FunctionReplaceParams.FunctionType.TASK) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.functionData()) - .isEqualTo( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") - assertThat(body.description()).isEqualTo("description") - assertThat(body.functionType()).isEqualTo(FunctionReplaceParams.FunctionType.TASK) - assertThat(body.origin()) - .isEqualTo( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - assertThat(body.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(body.tags()).isEqualTo(listOf("string")) + val params = FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(FunctionReplaceParams.FunctionType.TASK) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.functionData()).isEqualTo(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") + assertThat(body.description()).isEqualTo("description") + assertThat(body.functionType()).isEqualTo(FunctionReplaceParams.FunctionType.TASK) + assertThat(body.origin()).isEqualTo(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + assertThat(body.promptData()).isEqualTo(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + assertThat(body.tags()).isEqualTo(listOf("string")) } @Test fun getBodyWithoutOptionalFields() { - val params = - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.functionData()) - .isEqualTo( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + val params = FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.functionData()).isEqualTo(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt index e67f96c5..03c39ce5 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionRetrieveParamsTest.kt @@ -2,27 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.FunctionRetrieveParams class FunctionRetrieveParamsTest { @Test fun createFunctionRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt index e93fdd31..998317e8 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionTest.kt @@ -2,226 +2,133 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.Function class FunctionTest { @Test fun createFunction() { - val function = - Function.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - ._xactId("_xact_id") - .functionData( - Function.FunctionData.ofPrompt( - 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") - .functionType(Function.FunctionType.TASK) - .metadata(Function.Metadata.builder().build()) - .origin( - Function.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Function.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(function.description()).isEqualTo("description") - assertThat(function.functionType()).isEqualTo(Function.FunctionType.TASK) - assertThat(function.metadata()).isEqualTo(Function.Metadata.builder().build()) - assertThat(function.origin()) - .isEqualTo( - Function.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(Function.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - assertThat(function.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(function.tags()).containsExactly("string") + val function = Function.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + ._xactId("_xact_id") + .functionData(Function.FunctionData.ofPrompt(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") + .functionType(Function.FunctionType.TASK) + .metadata(Function.Metadata.builder().build()) + .origin(Function.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Function.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(function.description()).isEqualTo("description") + assertThat(function.functionType()).isEqualTo(Function.FunctionType.TASK) + assertThat(function.metadata()).isEqualTo(Function.Metadata.builder().build()) + assertThat(function.origin()).isEqualTo(Function.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(Function.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + assertThat(function.promptData()).isEqualTo(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + assertThat(function.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt index c1518249..29fe7385 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/FunctionUpdateParamsTest.kt @@ -2,311 +2,181 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.FunctionUpdateParams +import com.braintrustdata.api.models.FunctionUpdateParams.FunctionUpdateBody class FunctionUpdateParamsTest { @Test fun createFunctionUpdateParams() { - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.ofPrompt( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() + FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.ofPrompt(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build() } @Test fun getBody() { - val params = - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.ofPrompt( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.description()).isEqualTo("description") - assertThat(body.functionData()) - .isEqualTo( - FunctionUpdateParams.FunctionData.ofPrompt( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(body.name()).isEqualTo("name") - assertThat(body.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(body.tags()).isEqualTo(listOf("string")) + val params = FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.ofPrompt(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.description()).isEqualTo("description") + assertThat(body.functionData()).isEqualTo(FunctionUpdateParams.FunctionData.ofPrompt(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + assertThat(body.name()).isEqualTo("name") + assertThat(body.promptData()).isEqualTo(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + assertThat(body.tags()).isEqualTo(listOf("string")) } @Test fun getBodyWithoutOptionalFields() { - val params = - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt index b7b98eb3..501aab9c 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupCreateParamsTest.kt @@ -2,47 +2,60 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.GroupCreateParams +import com.braintrustdata.api.models.GroupCreateParams.GroupCreateBody class GroupCreateParamsTest { @Test fun createGroupCreateParams() { - GroupCreateParams.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() + GroupCreateParams.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() } @Test fun getBody() { - val params = - GroupCreateParams.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).isEqualTo("description") - assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + val params = GroupCreateParams.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).isEqualTo("description") + assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = GroupCreateParams.builder().name("name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = GroupCreateParams.builder() + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt index dd8a03f2..1d72eeb2 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupDeleteParamsTest.kt @@ -2,25 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.GroupDeleteParams class GroupDeleteParamsTest { @Test fun createGroupDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt index 33587c15..aad7f0da 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupListParamsTest.kt @@ -2,52 +2,59 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.GroupListParams class GroupListParamsTest { @Test fun createGroupListParams() { - GroupListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + GroupListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - GroupListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("group_name", listOf("group_name")) - expected.put( - "ids", - listOf(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = GroupListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupName("group_name") + .ids(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("group_name", listOf("group_name")) + expected.put("ids", listOf(GroupListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = GroupListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = GroupListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt index 4bc2570a..e11a015f 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupReplaceParamsTest.kt @@ -2,47 +2,60 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.GroupReplaceParams +import com.braintrustdata.api.models.GroupReplaceParams.GroupReplaceBody class GroupReplaceParamsTest { @Test fun createGroupReplaceParams() { - GroupReplaceParams.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() + GroupReplaceParams.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() } @Test fun getBody() { - val params = - GroupReplaceParams.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).isEqualTo("description") - assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + val params = GroupReplaceParams.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).isEqualTo("description") + assertThat(body.memberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.memberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = GroupReplaceParams.builder().name("name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = GroupReplaceParams.builder() + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt index 40cb190f..c4ea0a17 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupRetrieveParamsTest.kt @@ -2,25 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.GroupRetrieveParams class GroupRetrieveParamsTest { @Test fun createGroupRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt index 6305f5e3..a3a968a2 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupTest.kt @@ -2,35 +2,41 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.Group 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") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(group.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(group.description()).isEqualTo("description") - assertThat(group.memberGroups()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.memberUsers()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(group.userId()).isEqualTo("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") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(group.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(group.description()).isEqualTo("description") + assertThat(group.memberGroups()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.memberUsers()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(group.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt index f84d7191..217d9408 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/GroupUpdateParamsTest.kt @@ -2,65 +2,76 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.GroupUpdateParams +import com.braintrustdata.api.models.GroupUpdateParams.GroupUpdateBody class GroupUpdateParamsTest { @Test fun createGroupUpdateParams() { - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() + GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() } @Test fun getBody() { - val params = - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.addMemberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.addMemberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") - assertThat(body.removeMemberGroups()) - .isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.removeMemberUsers()) - .isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val params = GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.addMemberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.addMemberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).isEqualTo("description") + assertThat(body.name()).isEqualTo("name") + assertThat(body.removeMemberGroups()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.removeMemberUsers()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test fun getBodyWithoutOptionalFields() { - val params = - GroupUpdateParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() - assertThat(body).isNotNull + val params = GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt index ae5da7b1..f9b285b0 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventMergeTest.kt @@ -2,39 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.InsertDatasetEventMerge class InsertDatasetEventMergeTest { @Test fun createInsertDatasetEventMerge() { - val insertDatasetEventMerge = - InsertDatasetEventMerge.builder() - ._isMerge(true) - .id("id") - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEventMerge.Metadata.builder().build()) - .tags(listOf("string")) - .build() - assertThat(insertDatasetEventMerge).isNotNull - assertThat(insertDatasetEventMerge._isMerge()).isEqualTo(true) - assertThat(insertDatasetEventMerge.id()).isEqualTo("id") - assertThat(insertDatasetEventMerge._mergePaths()).containsExactly(listOf("string")) - assertThat(insertDatasetEventMerge._objectDelete()).isEqualTo(true) - assertThat(insertDatasetEventMerge.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertDatasetEventMerge._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertDatasetEventMerge._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(insertDatasetEventMerge.metadata()) - .isEqualTo(InsertDatasetEventMerge.Metadata.builder().build()) - assertThat(insertDatasetEventMerge.tags()).containsExactly("string") + val insertDatasetEventMerge = InsertDatasetEventMerge.builder() + ._isMerge(true) + .id("id") + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEventMerge.Metadata.builder().build()) + .tags(listOf("string")) + .build() + assertThat(insertDatasetEventMerge).isNotNull + assertThat(insertDatasetEventMerge._isMerge()).isEqualTo(true) + assertThat(insertDatasetEventMerge.id()).isEqualTo("id") + assertThat(insertDatasetEventMerge._mergePaths()).containsExactly(listOf("string")) + assertThat(insertDatasetEventMerge._objectDelete()).isEqualTo(true) + assertThat(insertDatasetEventMerge.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertDatasetEventMerge._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEventMerge._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEventMerge.metadata()).isEqualTo(InsertDatasetEventMerge.Metadata.builder().build()) + assertThat(insertDatasetEventMerge.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt index b98546a3..0fff7bb9 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventReplaceTest.kt @@ -2,40 +2,41 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.InsertDatasetEventReplace class InsertDatasetEventReplaceTest { @Test fun createInsertDatasetEventReplace() { - val insertDatasetEventReplace = - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - assertThat(insertDatasetEventReplace).isNotNull - assertThat(insertDatasetEventReplace.id()).isEqualTo("id") - assertThat(insertDatasetEventReplace._isMerge()).isEqualTo(true) - assertThat(insertDatasetEventReplace._objectDelete()).isEqualTo(true) - assertThat(insertDatasetEventReplace._parentId()).isEqualTo("_parent_id") - assertThat(insertDatasetEventReplace.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertDatasetEventReplace._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertDatasetEventReplace._input()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertDatasetEventReplace.metadata()) - .isEqualTo(InsertDatasetEventReplace.Metadata.builder().build()) - assertThat(insertDatasetEventReplace.tags()).containsExactly("string") + val insertDatasetEventReplace = InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) + .tags(listOf("string")) + .build() + assertThat(insertDatasetEventReplace).isNotNull + assertThat(insertDatasetEventReplace.id()).isEqualTo("id") + assertThat(insertDatasetEventReplace._isMerge()).isEqualTo(true) + assertThat(insertDatasetEventReplace._objectDelete()).isEqualTo(true) + assertThat(insertDatasetEventReplace._parentId()).isEqualTo("_parent_id") + assertThat(insertDatasetEventReplace.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertDatasetEventReplace._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEventReplace._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertDatasetEventReplace.metadata()).isEqualTo(InsertDatasetEventReplace.Metadata.builder().build()) + assertThat(insertDatasetEventReplace.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequestTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequestTest.kt deleted file mode 100755 index 0a75db1f..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertDatasetEventRequestTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InsertDatasetEventRequestTest { - - @Test - fun createInsertDatasetEventRequest() { - val insertDatasetEventRequest = - InsertDatasetEventRequest.builder() - .events( - listOf( - InsertDatasetEventRequest.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - assertThat(insertDatasetEventRequest).isNotNull - assertThat(insertDatasetEventRequest.events()) - .containsExactly( - InsertDatasetEventRequest.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - ) - ) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt index a55a1208..0ef0dee3 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertEventsResponseTest.kt @@ -2,15 +2,25 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.InsertEventsResponse class InsertEventsResponseTest { @Test fun createInsertEventsResponse() { - val insertEventsResponse = InsertEventsResponse.builder().rowIds(listOf("string")).build() - assertThat(insertEventsResponse).isNotNull - assertThat(insertEventsResponse.rowIds()).containsExactly("string") + val insertEventsResponse = InsertEventsResponse.builder() + .rowIds(listOf("string")) + .build() + assertThat(insertEventsResponse).isNotNull + assertThat(insertEventsResponse.rowIds()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt index 5b3a4955..a563dbfe 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventMergeTest.kt @@ -2,98 +2,81 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.InsertExperimentEventMerge class InsertExperimentEventMergeTest { @Test fun createInsertExperimentEventMerge() { - val insertExperimentEventMerge = - InsertExperimentEventMerge.builder() - ._isMerge(true) - .id("id") - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - .context( - InsertExperimentEventMerge.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEventMerge.Metadata.builder().build()) - .metrics( - InsertExperimentEventMerge.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertExperimentEventMerge.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventMerge.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventMerge.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(insertExperimentEventMerge).isNotNull - assertThat(insertExperimentEventMerge._isMerge()).isEqualTo(true) - assertThat(insertExperimentEventMerge.id()).isEqualTo("id") - assertThat(insertExperimentEventMerge._mergePaths()).containsExactly(listOf("string")) - assertThat(insertExperimentEventMerge._objectDelete()).isEqualTo(true) - assertThat(insertExperimentEventMerge.context()) - .isEqualTo( - InsertExperimentEventMerge.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - assertThat(insertExperimentEventMerge.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertExperimentEventMerge.datasetRecordId()).isEqualTo("dataset_record_id") - assertThat(insertExperimentEventMerge._error()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEventMerge._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEventMerge._input()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEventMerge.metadata()) - .isEqualTo(InsertExperimentEventMerge.Metadata.builder().build()) - assertThat(insertExperimentEventMerge.metrics()) - .isEqualTo( - InsertExperimentEventMerge.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - assertThat(insertExperimentEventMerge._output()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEventMerge.scores()) - .isEqualTo(InsertExperimentEventMerge.Scores.builder().build()) - assertThat(insertExperimentEventMerge.spanAttributes()) - .isEqualTo( - InsertExperimentEventMerge.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventMerge.SpanAttributes.Type.LLM) - .build() - ) - assertThat(insertExperimentEventMerge.tags()).containsExactly("string") + val insertExperimentEventMerge = InsertExperimentEventMerge.builder() + ._isMerge(true) + .id("id") + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + .context(InsertExperimentEventMerge.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEventMerge.Metadata.builder().build()) + .metrics(InsertExperimentEventMerge.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertExperimentEventMerge.Scores.builder().build()) + .spanAttributes(InsertExperimentEventMerge.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventMerge.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build() + assertThat(insertExperimentEventMerge).isNotNull + assertThat(insertExperimentEventMerge._isMerge()).isEqualTo(true) + assertThat(insertExperimentEventMerge.id()).isEqualTo("id") + assertThat(insertExperimentEventMerge._mergePaths()).containsExactly(listOf("string")) + assertThat(insertExperimentEventMerge._objectDelete()).isEqualTo(true) + assertThat(insertExperimentEventMerge.context()).isEqualTo(InsertExperimentEventMerge.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + assertThat(insertExperimentEventMerge.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertExperimentEventMerge.datasetRecordId()).isEqualTo("dataset_record_id") + assertThat(insertExperimentEventMerge._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventMerge._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventMerge._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventMerge.metadata()).isEqualTo(InsertExperimentEventMerge.Metadata.builder().build()) + assertThat(insertExperimentEventMerge.metrics()).isEqualTo(InsertExperimentEventMerge.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + assertThat(insertExperimentEventMerge._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventMerge.scores()).isEqualTo(InsertExperimentEventMerge.Scores.builder().build()) + assertThat(insertExperimentEventMerge.spanAttributes()).isEqualTo(InsertExperimentEventMerge.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventMerge.SpanAttributes.Type.LLM) + .build()) + assertThat(insertExperimentEventMerge.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt index 7e33d126..1bdcd060 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventReplaceTest.kt @@ -2,98 +2,81 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.InsertExperimentEventReplace class InsertExperimentEventReplaceTest { @Test fun createInsertExperimentEventReplace() { - val insertExperimentEventReplace = - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEventReplace.Metadata.builder().build()) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(insertExperimentEventReplace).isNotNull - assertThat(insertExperimentEventReplace.id()).isEqualTo("id") - assertThat(insertExperimentEventReplace._isMerge()).isEqualTo(true) - assertThat(insertExperimentEventReplace._objectDelete()).isEqualTo(true) - assertThat(insertExperimentEventReplace._parentId()).isEqualTo("_parent_id") - assertThat(insertExperimentEventReplace.context()) - .isEqualTo( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - assertThat(insertExperimentEventReplace.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertExperimentEventReplace.datasetRecordId()).isEqualTo("dataset_record_id") - assertThat(insertExperimentEventReplace._error()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEventReplace._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEventReplace._input()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEventReplace.metadata()) - .isEqualTo(InsertExperimentEventReplace.Metadata.builder().build()) - assertThat(insertExperimentEventReplace.metrics()) - .isEqualTo( - InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - assertThat(insertExperimentEventReplace._output()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertExperimentEventReplace.scores()) - .isEqualTo(InsertExperimentEventReplace.Scores.builder().build()) - assertThat(insertExperimentEventReplace.spanAttributes()) - .isEqualTo( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - assertThat(insertExperimentEventReplace.tags()).containsExactly("string") + val insertExperimentEventReplace = InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) + .metrics(InsertExperimentEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertExperimentEventReplace.Scores.builder().build()) + .spanAttributes(InsertExperimentEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build() + assertThat(insertExperimentEventReplace).isNotNull + assertThat(insertExperimentEventReplace.id()).isEqualTo("id") + assertThat(insertExperimentEventReplace._isMerge()).isEqualTo(true) + assertThat(insertExperimentEventReplace._objectDelete()).isEqualTo(true) + assertThat(insertExperimentEventReplace._parentId()).isEqualTo("_parent_id") + assertThat(insertExperimentEventReplace.context()).isEqualTo(InsertExperimentEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + assertThat(insertExperimentEventReplace.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertExperimentEventReplace.datasetRecordId()).isEqualTo("dataset_record_id") + assertThat(insertExperimentEventReplace._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventReplace._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventReplace._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventReplace.metadata()).isEqualTo(InsertExperimentEventReplace.Metadata.builder().build()) + assertThat(insertExperimentEventReplace.metrics()).isEqualTo(InsertExperimentEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + assertThat(insertExperimentEventReplace._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertExperimentEventReplace.scores()).isEqualTo(InsertExperimentEventReplace.Scores.builder().build()) + assertThat(insertExperimentEventReplace.spanAttributes()).isEqualTo(InsertExperimentEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .build()) + assertThat(insertExperimentEventReplace.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequestTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequestTest.kt deleted file mode 100755 index 8b5c690b..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertExperimentEventRequestTest.kt +++ /dev/null @@ -1,104 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InsertExperimentEventRequestTest { - - @Test - fun createInsertExperimentEventRequest() { - val insertExperimentEventRequest = - InsertExperimentEventRequest.builder() - .events( - listOf( - InsertExperimentEventRequest.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEventReplace.Metadata.builder().build()) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - assertThat(insertExperimentEventRequest).isNotNull - assertThat(insertExperimentEventRequest.events()) - .containsExactly( - InsertExperimentEventRequest.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertExperimentEventReplace.Metadata.builder().build()) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt index 4846aee1..6c9ba5dd 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventMergeTest.kt @@ -2,96 +2,79 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.InsertProjectLogsEventMerge class InsertProjectLogsEventMergeTest { @Test fun createInsertProjectLogsEventMerge() { - val insertProjectLogsEventMerge = - InsertProjectLogsEventMerge.builder() - ._isMerge(true) - .id("id") - ._mergePaths(listOf(listOf("string"))) - ._objectDelete(true) - .context( - InsertProjectLogsEventMerge.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEventMerge.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventMerge.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertProjectLogsEventMerge.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventMerge.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventMerge.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(insertProjectLogsEventMerge).isNotNull - assertThat(insertProjectLogsEventMerge._isMerge()).isEqualTo(true) - assertThat(insertProjectLogsEventMerge.id()).isEqualTo("id") - assertThat(insertProjectLogsEventMerge._mergePaths()).containsExactly(listOf("string")) - assertThat(insertProjectLogsEventMerge._objectDelete()).isEqualTo(true) - assertThat(insertProjectLogsEventMerge.context()) - .isEqualTo( - InsertProjectLogsEventMerge.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - assertThat(insertProjectLogsEventMerge.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertProjectLogsEventMerge._error()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEventMerge._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEventMerge._input()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEventMerge.metadata()) - .isEqualTo(InsertProjectLogsEventMerge.Metadata.builder().build()) - assertThat(insertProjectLogsEventMerge.metrics()) - .isEqualTo( - InsertProjectLogsEventMerge.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - assertThat(insertProjectLogsEventMerge._output()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEventMerge.scores()) - .isEqualTo(InsertProjectLogsEventMerge.Scores.builder().build()) - assertThat(insertProjectLogsEventMerge.spanAttributes()) - .isEqualTo( - InsertProjectLogsEventMerge.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventMerge.SpanAttributes.Type.LLM) - .build() - ) - assertThat(insertProjectLogsEventMerge.tags()).containsExactly("string") + val insertProjectLogsEventMerge = InsertProjectLogsEventMerge.builder() + ._isMerge(true) + .id("id") + ._mergePaths(listOf(listOf("string"))) + ._objectDelete(true) + .context(InsertProjectLogsEventMerge.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEventMerge.Metadata.builder().build()) + .metrics(InsertProjectLogsEventMerge.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertProjectLogsEventMerge.Scores.builder().build()) + .spanAttributes(InsertProjectLogsEventMerge.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventMerge.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build() + assertThat(insertProjectLogsEventMerge).isNotNull + assertThat(insertProjectLogsEventMerge._isMerge()).isEqualTo(true) + assertThat(insertProjectLogsEventMerge.id()).isEqualTo("id") + assertThat(insertProjectLogsEventMerge._mergePaths()).containsExactly(listOf("string")) + assertThat(insertProjectLogsEventMerge._objectDelete()).isEqualTo(true) + assertThat(insertProjectLogsEventMerge.context()).isEqualTo(InsertProjectLogsEventMerge.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + assertThat(insertProjectLogsEventMerge.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertProjectLogsEventMerge._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventMerge._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventMerge._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventMerge.metadata()).isEqualTo(InsertProjectLogsEventMerge.Metadata.builder().build()) + assertThat(insertProjectLogsEventMerge.metrics()).isEqualTo(InsertProjectLogsEventMerge.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + assertThat(insertProjectLogsEventMerge._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventMerge.scores()).isEqualTo(InsertProjectLogsEventMerge.Scores.builder().build()) + assertThat(insertProjectLogsEventMerge.spanAttributes()).isEqualTo(InsertProjectLogsEventMerge.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventMerge.SpanAttributes.Type.LLM) + .build()) + assertThat(insertProjectLogsEventMerge.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt index 2003d463..c13c2bd5 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventReplaceTest.kt @@ -2,96 +2,79 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.InsertProjectLogsEventReplace class InsertProjectLogsEventReplaceTest { @Test fun createInsertProjectLogsEventReplace() { - val insertProjectLogsEventReplace = - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(insertProjectLogsEventReplace).isNotNull - assertThat(insertProjectLogsEventReplace.id()).isEqualTo("id") - assertThat(insertProjectLogsEventReplace._isMerge()).isEqualTo(true) - assertThat(insertProjectLogsEventReplace._objectDelete()).isEqualTo(true) - assertThat(insertProjectLogsEventReplace._parentId()).isEqualTo("_parent_id") - assertThat(insertProjectLogsEventReplace.context()) - .isEqualTo( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - assertThat(insertProjectLogsEventReplace.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(insertProjectLogsEventReplace._error()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEventReplace._expected()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEventReplace._input()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEventReplace.metadata()) - .isEqualTo(InsertProjectLogsEventReplace.Metadata.builder().build()) - assertThat(insertProjectLogsEventReplace.metrics()) - .isEqualTo( - InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - assertThat(insertProjectLogsEventReplace._output()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(insertProjectLogsEventReplace.scores()) - .isEqualTo(InsertProjectLogsEventReplace.Scores.builder().build()) - assertThat(insertProjectLogsEventReplace.spanAttributes()) - .isEqualTo( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - assertThat(insertProjectLogsEventReplace.tags()).containsExactly("string") + val insertProjectLogsEventReplace = InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) + .metrics(InsertProjectLogsEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) + .spanAttributes(InsertProjectLogsEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build() + assertThat(insertProjectLogsEventReplace).isNotNull + assertThat(insertProjectLogsEventReplace.id()).isEqualTo("id") + assertThat(insertProjectLogsEventReplace._isMerge()).isEqualTo(true) + assertThat(insertProjectLogsEventReplace._objectDelete()).isEqualTo(true) + assertThat(insertProjectLogsEventReplace._parentId()).isEqualTo("_parent_id") + assertThat(insertProjectLogsEventReplace.context()).isEqualTo(InsertProjectLogsEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + assertThat(insertProjectLogsEventReplace.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(insertProjectLogsEventReplace._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventReplace._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventReplace._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventReplace.metadata()).isEqualTo(InsertProjectLogsEventReplace.Metadata.builder().build()) + assertThat(insertProjectLogsEventReplace.metrics()).isEqualTo(InsertProjectLogsEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + assertThat(insertProjectLogsEventReplace._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(insertProjectLogsEventReplace.scores()).isEqualTo(InsertProjectLogsEventReplace.Scores.builder().build()) + assertThat(insertProjectLogsEventReplace.spanAttributes()).isEqualTo(InsertProjectLogsEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .build()) + assertThat(insertProjectLogsEventReplace.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequestTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequestTest.kt deleted file mode 100755 index 9a98166f..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/InsertProjectLogsEventRequestTest.kt +++ /dev/null @@ -1,102 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InsertProjectLogsEventRequestTest { - - @Test - fun createInsertProjectLogsEventRequest() { - val insertProjectLogsEventRequest = - InsertProjectLogsEventRequest.builder() - .events( - listOf( - InsertProjectLogsEventRequest.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - assertThat(insertProjectLogsEventRequest).isNotNull - assertThat(insertProjectLogsEventRequest.events()) - .containsExactly( - InsertProjectLogsEventRequest.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt index 028cc804..bdeb8703 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/MetricSummaryTest.kt @@ -2,28 +2,35 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.MetricSummary class MetricSummaryTest { @Test fun createMetricSummary() { - val metricSummary = - MetricSummary.builder() - .improvements(123L) - .metric(42.23) - .name("name") - .regressions(123L) - .unit("unit") - .diff(42.23) - .build() - assertThat(metricSummary).isNotNull - assertThat(metricSummary.improvements()).isEqualTo(123L) - assertThat(metricSummary.metric()).isEqualTo(42.23) - assertThat(metricSummary.name()).isEqualTo("name") - assertThat(metricSummary.regressions()).isEqualTo(123L) - assertThat(metricSummary.unit()).isEqualTo("unit") - assertThat(metricSummary.diff()).isEqualTo(42.23) + val metricSummary = MetricSummary.builder() + .improvements(123L) + .metric(42.23) + .name("name") + .regressions(123L) + .unit("unit") + .diff(42.23) + .build() + assertThat(metricSummary).isNotNull + assertThat(metricSummary.improvements()).isEqualTo(123L) + assertThat(metricSummary.metric()).isEqualTo(42.23) + assertThat(metricSummary.name()).isEqualTo("name") + assertThat(metricSummary.regressions()).isEqualTo(123L) + assertThat(metricSummary.unit()).isEqualTo("unit") + assertThat(metricSummary.diff()).isEqualTo(42.23) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretCreateParamsTest.kt index 1b409e00..df34ab2b 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretCreateParamsTest.kt @@ -2,47 +2,60 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrgSecretCreateParams +import com.braintrustdata.api.models.OrgSecretCreateParams.OrgSecretCreateBody class OrgSecretCreateParamsTest { @Test fun createOrgSecretCreateParams() { - OrgSecretCreateParams.builder() - .name("name") - .metadata(OrgSecretCreateParams.Metadata.builder().build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build() + OrgSecretCreateParams.builder() + .name("name") + .metadata(OrgSecretCreateParams.Metadata.builder().build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() } @Test fun getBody() { - val params = - OrgSecretCreateParams.builder() - .name("name") - .metadata(OrgSecretCreateParams.Metadata.builder().build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.metadata()).isEqualTo(OrgSecretCreateParams.Metadata.builder().build()) - assertThat(body.orgName()).isEqualTo("org_name") - assertThat(body.secret()).isEqualTo("secret") - assertThat(body.type()).isEqualTo("type") + val params = OrgSecretCreateParams.builder() + .name("name") + .metadata(OrgSecretCreateParams.Metadata.builder().build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.metadata()).isEqualTo(OrgSecretCreateParams.Metadata.builder().build()) + assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.secret()).isEqualTo("secret") + assertThat(body.type()).isEqualTo("type") } @Test fun getBodyWithoutOptionalFields() { - val params = OrgSecretCreateParams.builder().name("name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = OrgSecretCreateParams.builder() + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretDeleteParamsTest.kt index 3dbacbc3..5cab3d7e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretDeleteParamsTest.kt @@ -2,27 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrgSecretDeleteParams class OrgSecretDeleteParamsTest { @Test fun createOrgSecretDeleteParams() { - OrgSecretDeleteParams.builder().orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + OrgSecretDeleteParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - OrgSecretDeleteParams.builder() - .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "orgSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = OrgSecretDeleteParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "orgSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretListParamsTest.kt index 69c5d0f6..39992a43 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretListParamsTest.kt @@ -2,60 +2,62 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrgSecretListParams class OrgSecretListParamsTest { @Test fun createOrgSecretListParams() { - OrgSecretListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(OrgSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .orgSecretName("org_secret_name") - .orgSecretType(OrgSecretListParams.OrgSecretType.ofString("string")) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrgSecretListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(OrgSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .orgSecretName("org_secret_name") + .orgSecretType(OrgSecretListParams.OrgSecretType.ofString("string")) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - OrgSecretListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(OrgSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .orgSecretName("org_secret_name") - .orgSecretType(OrgSecretListParams.OrgSecretType.ofString("string")) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf( - OrgSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("org_secret_name", listOf("org_secret_name")) - expected.put( - "org_secret_type", - listOf(OrgSecretListParams.OrgSecretType.ofString("string").toString()) - ) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = OrgSecretListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(OrgSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .orgSecretName("org_secret_name") + .orgSecretType(OrgSecretListParams.OrgSecretType.ofString("string")) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(OrgSecretListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("org_secret_name", listOf("org_secret_name")) + expected.put("org_secret_type", listOf(OrgSecretListParams.OrgSecretType.ofString("string").toString())) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = OrgSecretListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = OrgSecretListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretReplaceParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretReplaceParamsTest.kt index 8c5a57ac..979a8d98 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretReplaceParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretReplaceParamsTest.kt @@ -2,47 +2,60 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrgSecretReplaceParams +import com.braintrustdata.api.models.OrgSecretReplaceParams.OrgSecretReplaceBody class OrgSecretReplaceParamsTest { @Test fun createOrgSecretReplaceParams() { - OrgSecretReplaceParams.builder() - .name("name") - .metadata(OrgSecretReplaceParams.Metadata.builder().build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build() + OrgSecretReplaceParams.builder() + .name("name") + .metadata(OrgSecretReplaceParams.Metadata.builder().build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() } @Test fun getBody() { - val params = - OrgSecretReplaceParams.builder() - .name("name") - .metadata(OrgSecretReplaceParams.Metadata.builder().build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.metadata()).isEqualTo(OrgSecretReplaceParams.Metadata.builder().build()) - assertThat(body.orgName()).isEqualTo("org_name") - assertThat(body.secret()).isEqualTo("secret") - assertThat(body.type()).isEqualTo("type") + val params = OrgSecretReplaceParams.builder() + .name("name") + .metadata(OrgSecretReplaceParams.Metadata.builder().build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.metadata()).isEqualTo(OrgSecretReplaceParams.Metadata.builder().build()) + assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.secret()).isEqualTo("secret") + assertThat(body.type()).isEqualTo("type") } @Test fun getBodyWithoutOptionalFields() { - val params = OrgSecretReplaceParams.builder().name("name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = OrgSecretReplaceParams.builder() + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretRetrieveParamsTest.kt index d22d2980..fe48c4fc 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretRetrieveParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrgSecretRetrieveParams class OrgSecretRetrieveParamsTest { @Test fun createOrgSecretRetrieveParams() { - OrgSecretRetrieveParams.builder() - .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrgSecretRetrieveParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getPathParam() { - val params = - OrgSecretRetrieveParams.builder() - .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "orgSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = OrgSecretRetrieveParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "orgSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretTest.kt index 24865e94..7391f43d 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretTest.kt @@ -2,31 +2,37 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.OrgSecret class OrgSecretTest { @Test fun createOrgSecret() { - val orgSecret = - OrgSecret.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(OrgSecret.Metadata.builder().build()) - .previewSecret("preview_secret") - .type("type") - .build() - assertThat(orgSecret).isNotNull - assertThat(orgSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(orgSecret.name()).isEqualTo("name") - assertThat(orgSecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(orgSecret.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(orgSecret.metadata()).isEqualTo(OrgSecret.Metadata.builder().build()) - assertThat(orgSecret.previewSecret()).isEqualTo("preview_secret") - assertThat(orgSecret.type()).isEqualTo("type") + val orgSecret = OrgSecret.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(OrgSecret.Metadata.builder().build()) + .previewSecret("preview_secret") + .type("type") + .build() + assertThat(orgSecret).isNotNull + assertThat(orgSecret.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgSecret.name()).isEqualTo("name") + assertThat(orgSecret.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(orgSecret.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(orgSecret.metadata()).isEqualTo(OrgSecret.Metadata.builder().build()) + assertThat(orgSecret.previewSecret()).isEqualTo("preview_secret") + assertThat(orgSecret.type()).isEqualTo("type") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretUpdateParamsTest.kt index abee260a..0a7551dc 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrgSecretUpdateParamsTest.kt @@ -2,61 +2,70 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrgSecretUpdateParams +import com.braintrustdata.api.models.OrgSecretUpdateParams.OrgSecretUpdateBody class OrgSecretUpdateParamsTest { @Test fun createOrgSecretUpdateParams() { - OrgSecretUpdateParams.builder() - .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(OrgSecretUpdateParams.Metadata.builder().build()) - .name("name") - .secret("secret") - .type("type") - .build() + OrgSecretUpdateParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(OrgSecretUpdateParams.Metadata.builder().build()) + .name("name") + .secret("secret") + .type("type") + .build() } @Test fun getBody() { - val params = - OrgSecretUpdateParams.builder() - .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(OrgSecretUpdateParams.Metadata.builder().build()) - .name("name") - .secret("secret") - .type("type") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.metadata()).isEqualTo(OrgSecretUpdateParams.Metadata.builder().build()) - assertThat(body.name()).isEqualTo("name") - assertThat(body.secret()).isEqualTo("secret") - assertThat(body.type()).isEqualTo("type") + val params = OrgSecretUpdateParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(OrgSecretUpdateParams.Metadata.builder().build()) + .name("name") + .secret("secret") + .type("type") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.metadata()).isEqualTo(OrgSecretUpdateParams.Metadata.builder().build()) + assertThat(body.name()).isEqualTo("name") + assertThat(body.secret()).isEqualTo("secret") + assertThat(body.type()).isEqualTo("type") } @Test fun getBodyWithoutOptionalFields() { - val params = - OrgSecretUpdateParams.builder() - .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = OrgSecretUpdateParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @Test fun getPathParam() { - val params = - OrgSecretUpdateParams.builder() - .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "orgSecretId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val params = OrgSecretUpdateParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "orgSecretId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt index 1c6fe6ac..400c2a75 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationDeleteParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrganizationDeleteParams class OrganizationDeleteParamsTest { @Test fun createOrganizationDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt index 59b904b0..9efd87c1 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationListParamsTest.kt @@ -2,52 +2,56 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrganizationListParams class OrganizationListParamsTest { @Test fun createOrganizationListParams() { - OrganizationListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + OrganizationListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - OrganizationListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf( - OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .toString() - ) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = OrganizationListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(OrganizationListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = OrganizationListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = OrganizationListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt index 99b5aca9..fc446ade 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateParamsTest.kt @@ -2,90 +2,87 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrganizationMemberUpdateParams +import com.braintrustdata.api.models.OrganizationMemberUpdateParams.OrganizationMemberUpdateBody class OrganizationMemberUpdateParamsTest { @Test fun createOrganizationMemberUpdateParams() { - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .emails(listOf("string")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .groupName("group_name") - .groupNames(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - ) - .build() + OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .emails(listOf("string")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .groupName("group_name") + .groupNames(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .emails(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build()) + .build() } @Test fun getBody() { - val params = - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .emails(listOf("string")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .groupName("group_name") - .groupNames(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.inviteUsers()) - .isEqualTo( - OrganizationMemberUpdateParams.InviteUsers.builder() - .emails(listOf("string")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .groupName("group_name") - .groupNames(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .sendInviteEmails(true) - .build() - ) - assertThat(body.orgId()).isEqualTo("org_id") - assertThat(body.orgName()).isEqualTo("org_name") - assertThat(body.removeUsers()) - .isEqualTo( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - ) + val params = OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .emails(listOf("string")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .groupName("group_name") + .groupNames(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .emails(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build()) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.inviteUsers()).isEqualTo(OrganizationMemberUpdateParams.InviteUsers.builder() + .emails(listOf("string")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .groupName("group_name") + .groupNames(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .sendInviteEmails(true) + .build()) + assertThat(body.orgId()).isEqualTo("org_id") + assertThat(body.orgName()).isEqualTo("org_name") + assertThat(body.removeUsers()).isEqualTo(OrganizationMemberUpdateParams.RemoveUsers.builder() + .emails(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build()) } @Test fun getBodyWithoutOptionalFields() { - val params = OrganizationMemberUpdateParams.builder().build() - val body = params.getBody() - assertThat(body).isNotNull + val params = OrganizationMemberUpdateParams.builder().build() + val body = params.getBody() + assertThat(body).isNotNull } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponseTest.kt index a479dac4..95306714 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponseTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationMemberUpdateResponseTest.kt @@ -2,21 +2,27 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.OrganizationMemberUpdateResponse class OrganizationMemberUpdateResponseTest { @Test fun createOrganizationMemberUpdateResponse() { - val organizationMemberUpdateResponse = - OrganizationMemberUpdateResponse.builder() - .status(OrganizationMemberUpdateResponse.Status.SUCCESS) - .sendEmailError("send_email_error") - .build() - assertThat(organizationMemberUpdateResponse).isNotNull - assertThat(organizationMemberUpdateResponse.status()) - .isEqualTo(OrganizationMemberUpdateResponse.Status.SUCCESS) - assertThat(organizationMemberUpdateResponse.sendEmailError()).isEqualTo("send_email_error") + val organizationMemberUpdateResponse = OrganizationMemberUpdateResponse.builder() + .status(OrganizationMemberUpdateResponse.Status.SUCCESS) + .sendEmailError("send_email_error") + .build() + assertThat(organizationMemberUpdateResponse).isNotNull + assertThat(organizationMemberUpdateResponse.status()).isEqualTo(OrganizationMemberUpdateResponse.Status.SUCCESS) + assertThat(organizationMemberUpdateResponse.sendEmailError()).isEqualTo("send_email_error") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt index 4ccbda0e..0a93672d 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationRetrieveParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrganizationRetrieveParams class OrganizationRetrieveParamsTest { @Test fun createOrganizationRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt index 5296d7d8..dd242cce 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationTest.kt @@ -2,32 +2,37 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.Organization 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()).isEqualTo("api_url") - assertThat(organization.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(organization.isUniversalApi()).isEqualTo(true) - assertThat(organization.proxyUrl()).isEqualTo("proxy_url") - assertThat(organization.realtimeUrl()).isEqualTo("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()).isEqualTo("api_url") + assertThat(organization.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(organization.isUniversalApi()).isEqualTo(true) + assertThat(organization.proxyUrl()).isEqualTo("proxy_url") + assertThat(organization.realtimeUrl()).isEqualTo("realtime_url") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt index cc38ee32..c3f135b4 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/OrganizationUpdateParamsTest.kt @@ -2,64 +2,73 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.OrganizationUpdateParams +import com.braintrustdata.api.models.OrganizationUpdateParams.OrganizationUpdateBody class OrganizationUpdateParamsTest { @Test fun createOrganizationUpdateParams() { - 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 getBody() { - 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.getBody() - assertThat(body).isNotNull - assertThat(body.apiUrl()).isEqualTo("api_url") - assertThat(body.isUniversalApi()).isEqualTo(true) - assertThat(body.name()).isEqualTo("name") - assertThat(body.proxyUrl()).isEqualTo("proxy_url") - assertThat(body.realtimeUrl()).isEqualTo("realtime_url") + 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.getBody() + assertThat(body).isNotNull + assertThat(body.apiUrl()).isEqualTo("api_url") + assertThat(body.isUniversalApi()).isEqualTo(true) + assertThat(body.name()).isEqualTo("name") + assertThat(body.proxyUrl()).isEqualTo("proxy_url") + assertThat(body.realtimeUrl()).isEqualTo("realtime_url") } @Test fun getBodyWithoutOptionalFields() { - val params = - OrganizationUpdateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = OrganizationUpdateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchDatasetTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchDatasetTest.kt deleted file mode 100755 index ac1edbbd..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchDatasetTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchDatasetTest { - - @Test - fun createPatchDataset() { - val patchDataset = - PatchDataset.builder() - .description("description") - .metadata(PatchDataset.Metadata.builder().build()) - .name("name") - .build() - assertThat(patchDataset).isNotNull - assertThat(patchDataset.description()).isEqualTo("description") - assertThat(patchDataset.metadata()).isEqualTo(PatchDataset.Metadata.builder().build()) - assertThat(patchDataset.name()).isEqualTo("name") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchExperimentTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchExperimentTest.kt deleted file mode 100755 index e51efb6c..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchExperimentTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchExperimentTest { - - @Test - fun createPatchExperiment() { - val patchExperiment = - PatchExperiment.builder() - .baseExpId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .datasetVersion("dataset_version") - .description("description") - .metadata(PatchExperiment.Metadata.builder().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() - assertThat(patchExperiment).isNotNull - assertThat(patchExperiment.baseExpId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(patchExperiment.datasetId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(patchExperiment.datasetVersion()).isEqualTo("dataset_version") - assertThat(patchExperiment.description()).isEqualTo("description") - assertThat(patchExperiment.metadata()).isEqualTo(PatchExperiment.Metadata.builder().build()) - assertThat(patchExperiment.name()).isEqualTo("name") - assertThat(patchExperiment.public_()).isEqualTo(true) - assertThat(patchExperiment.repoInfo()) - .isEqualTo( - RepoInfo.builder() - .authorEmail("author_email") - .authorName("author_name") - .branch("branch") - .commit("commit") - .commitMessage("commit_message") - .commitTime("commit_time") - .dirty(true) - .gitDiff("git_diff") - .tag("tag") - .build() - ) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchFunctionTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchFunctionTest.kt deleted file mode 100755 index e641a967..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchFunctionTest.kt +++ /dev/null @@ -1,179 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchFunctionTest { - - @Test - fun createPatchFunction() { - val patchFunction = - PatchFunction.builder() - .description("description") - .functionData( - PatchFunction.FunctionData.ofPrompt( - PatchFunction.FunctionData.Prompt.builder() - .type(PatchFunction.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(patchFunction).isNotNull - assertThat(patchFunction.description()).isEqualTo("description") - assertThat(patchFunction.functionData()) - .isEqualTo( - PatchFunction.FunctionData.ofPrompt( - PatchFunction.FunctionData.Prompt.builder() - .type(PatchFunction.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - assertThat(patchFunction.name()).isEqualTo("name") - assertThat(patchFunction.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(patchFunction.tags()).containsExactly("string") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchGroupTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchGroupTest.kt deleted file mode 100755 index d6163ee9..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchGroupTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchGroupTest { - - @Test - fun createPatchGroup() { - val patchGroup = - PatchGroup.builder() - .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - assertThat(patchGroup).isNotNull - assertThat(patchGroup.addMemberGroups()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(patchGroup.addMemberUsers()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(patchGroup.description()).isEqualTo("description") - assertThat(patchGroup.name()).isEqualTo("name") - assertThat(patchGroup.removeMemberGroups()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(patchGroup.removeMemberUsers()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersTest.kt deleted file mode 100755 index 10427b74..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationMembersTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchOrganizationMembersTest { - - @Test - fun createPatchOrganizationMembers() { - val patchOrganizationMembers = - PatchOrganizationMembers.builder() - .inviteUsers( - PatchOrganizationMembers.InviteUsers.builder() - .emails(listOf("string")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - PatchOrganizationMembers.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - ) - .build() - assertThat(patchOrganizationMembers).isNotNull - assertThat(patchOrganizationMembers.inviteUsers()) - .isEqualTo( - PatchOrganizationMembers.InviteUsers.builder() - .emails(listOf("string")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .sendInviteEmails(true) - .build() - ) - assertThat(patchOrganizationMembers.orgId()).isEqualTo("org_id") - assertThat(patchOrganizationMembers.orgName()).isEqualTo("org_name") - assertThat(patchOrganizationMembers.removeUsers()) - .isEqualTo( - PatchOrganizationMembers.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - ) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationTest.kt deleted file mode 100755 index 75c13b4a..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchOrganizationTest.kt +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchOrganizationTest { - - @Test - fun createPatchOrganization() { - val patchOrganization = - PatchOrganization.builder() - .apiUrl("api_url") - .isUniversalApi(true) - .name("name") - .proxyUrl("proxy_url") - .realtimeUrl("realtime_url") - .build() - assertThat(patchOrganization).isNotNull - assertThat(patchOrganization.apiUrl()).isEqualTo("api_url") - assertThat(patchOrganization.isUniversalApi()).isEqualTo(true) - assertThat(patchOrganization.name()).isEqualTo("name") - assertThat(patchOrganization.proxyUrl()).isEqualTo("proxy_url") - assertThat(patchOrganization.realtimeUrl()).isEqualTo("realtime_url") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectScoreTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectScoreTest.kt deleted file mode 100755 index 04b70c46..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectScoreTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchProjectScoreTest { - - @Test - fun createPatchProjectScore() { - val patchProjectScore = - PatchProjectScore.builder() - .categories( - PatchProjectScore.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .name("name") - .scoreType(PatchProjectScore.ScoreType.SLIDER) - .build() - assertThat(patchProjectScore).isNotNull - assertThat(patchProjectScore.categories()) - .isEqualTo( - PatchProjectScore.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - assertThat(patchProjectScore.description()).isEqualTo("description") - assertThat(patchProjectScore.name()).isEqualTo("name") - assertThat(patchProjectScore.scoreType()).isEqualTo(PatchProjectScore.ScoreType.SLIDER) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTagTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTagTest.kt deleted file mode 100755 index 0ab8a897..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTagTest.kt +++ /dev/null @@ -1,19 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchProjectTagTest { - - @Test - fun createPatchProjectTag() { - val patchProjectTag = - PatchProjectTag.builder().color("color").description("description").name("name").build() - assertThat(patchProjectTag).isNotNull - assertThat(patchProjectTag.color()).isEqualTo("color") - assertThat(patchProjectTag.description()).isEqualTo("description") - assertThat(patchProjectTag.name()).isEqualTo("name") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTest.kt deleted file mode 100755 index 99085776..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchProjectTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchProjectTest { - - @Test - fun createPatchProject() { - val patchProject = - PatchProject.builder() - .name("name") - .settings(PatchProject.Settings.builder().comparisonKey("comparison_key").build()) - .build() - assertThat(patchProject).isNotNull - assertThat(patchProject.name()).isEqualTo("name") - assertThat(patchProject.settings()) - .isEqualTo(PatchProject.Settings.builder().comparisonKey("comparison_key").build()) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchPromptTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchPromptTest.kt deleted file mode 100755 index b49553a7..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchPromptTest.kt +++ /dev/null @@ -1,164 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchPromptTest { - - @Test - fun createPatchPrompt() { - val patchPrompt = - PatchPrompt.builder() - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - assertThat(patchPrompt).isNotNull - assertThat(patchPrompt.description()).isEqualTo("description") - assertThat(patchPrompt.name()).isEqualTo("name") - assertThat(patchPrompt.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(patchPrompt.tags()).containsExactly("string") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchRoleTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchRoleTest.kt deleted file mode 100755 index df51d1d5..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchRoleTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchRoleTest { - - @Test - fun createPatchRole() { - val patchRole = - PatchRole.builder() - .addMemberPermissions( - listOf( - PatchRole.AddMemberPermission.builder() - .permission(PatchRole.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - PatchRole.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberPermissions( - listOf( - PatchRole.RemoveMemberPermission.builder() - .permission(PatchRole.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - PatchRole.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - assertThat(patchRole).isNotNull - assertThat(patchRole.addMemberPermissions()) - .containsExactly( - PatchRole.AddMemberPermission.builder() - .permission(PatchRole.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - PatchRole.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - assertThat(patchRole.addMemberRoles()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(patchRole.description()).isEqualTo("description") - assertThat(patchRole.name()).isEqualTo("name") - assertThat(patchRole.removeMemberPermissions()) - .containsExactly( - PatchRole.RemoveMemberPermission.builder() - .permission(PatchRole.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - PatchRole.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - assertThat(patchRole.removeMemberRoles()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchViewTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchViewTest.kt deleted file mode 100755 index 50b8d166..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PatchViewTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class PatchViewTest { - - @Test - fun createPatchView() { - val patchView = - PatchView.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(PatchView.ObjectType.ORGANIZATION) - .name("name") - .options( - ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - .viewType(PatchView.ViewType.PROJECTS) - .build() - assertThat(patchView).isNotNull - assertThat(patchView.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(patchView.objectType()).isEqualTo(PatchView.ObjectType.ORGANIZATION) - assertThat(patchView.name()).isEqualTo("name") - assertThat(patchView.options()) - .isEqualTo( - ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - assertThat(patchView.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(patchView.viewData()) - .isEqualTo( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - assertThat(patchView.viewType()).isEqualTo(PatchView.ViewType.PROJECTS) - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt index ed4abcb9..e4bf166f 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PathLookupFilterTest.kt @@ -2,23 +2,29 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.PathLookupFilter class PathLookupFilterTest { @Test fun createPathLookupFilter() { - val pathLookupFilter = - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - assertThat(pathLookupFilter).isNotNull - assertThat(pathLookupFilter.path()).containsExactly("string") - assertThat(pathLookupFilter.type()).isEqualTo(PathLookupFilter.Type.PATH_LOOKUP) - assertThat(pathLookupFilter._value()).isEqualTo(JsonValue.from(mapOf())) + val pathLookupFilter = PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build() + assertThat(pathLookupFilter).isNotNull + assertThat(pathLookupFilter.path()).containsExactly("string") + assertThat(pathLookupFilter.type()).isEqualTo(PathLookupFilter.Type.PATH_LOOKUP) + assertThat(pathLookupFilter._value()).isEqualTo(JsonValue.from(mapOf())) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt index 10928d7b..4181ba3c 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectCreateParamsTest.kt @@ -2,31 +2,51 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectCreateParams +import com.braintrustdata.api.models.ProjectCreateParams.ProjectCreateBody class ProjectCreateParamsTest { @Test fun createProjectCreateParams() { - ProjectCreateParams.builder().name("name").orgName("org_name").build() + ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() } @Test fun getBody() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.orgName()).isEqualTo("org_name") + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = ProjectCreateParams.builder().name("name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = ProjectCreateParams.builder() + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt index caa2ac8b..6011973d 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectDeleteParamsTest.kt @@ -2,25 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectDeleteParams class ProjectDeleteParamsTest { @Test fun createProjectDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt index 233ceaa7..fbc80cc6 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectListParamsTest.kt @@ -2,54 +2,59 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectListParams class ProjectListParamsTest { @Test fun createProjectListParams() { - ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - ProjectListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectName("project_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf( - ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_name", listOf("project_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ProjectListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectName("project_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(ProjectListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_name", listOf("project_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = ProjectListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ProjectListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt index 021b6567..90cffb5e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFeedbackParamsTest.kt @@ -2,91 +2,91 @@ package com.braintrustdata.api.models +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID +import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test +import com.braintrustdata.api.models.ProjectLogFeedbackParams +import com.braintrustdata.api.models.ProjectLogFeedbackParams.ProjectLogFeedbackBody class ProjectLogFeedbackParamsTest { @Test fun createProjectLogFeedbackParams() { - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .build() - ) - ) - .build() + ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) + .build())) + .build() } @Test fun getBody() { - val params = - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .build() - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()) - .isEqualTo( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .build() - ) - ) + val params = ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) + .build())) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()).isEqualTo(listOf(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) + .build())) } @Test fun getBodyWithoutOptionalFields() { - val params = - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(FeedbackProjectLogsItem.builder().id("id").build())) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.feedback()) - .isEqualTo(listOf(FeedbackProjectLogsItem.builder().id("id").build())) + val params = ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackProjectLogsItem.builder() + .id("id") + .build())) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.feedback()).isEqualTo(listOf(FeedbackProjectLogsItem.builder() + .id("id") + .build())) } @Test fun getPathParam() { - val params = - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback(listOf(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") + .feedback(listOf(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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt index c84026c0..02d7615c 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchParamsTest.kt @@ -2,61 +2,69 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectLogFetchParams class ProjectLogFetchParamsTest { @Test fun createProjectLogFetchParams() { - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getQueryParams() { - val params = - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val expected = mutableMapOf>() - expected.put("limit", listOf("123")) - expected.put("max_root_span_id", listOf("max_root_span_id")) - expected.put("max_xact_id", listOf("max_xact_id")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val expected = mutableMapOf>() + expected.put("limit", listOf("123")) + expected.put("max_root_span_id", listOf("max_root_span_id")) + expected.put("max_xact_id", listOf("max_xact_id")) + expected.put("version", listOf("version")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt index 8e3129b1..a9e46329 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostParamsTest.kt @@ -2,93 +2,88 @@ package com.braintrustdata.api.models +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID +import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test +import com.braintrustdata.api.models.ProjectLogFetchPostParams +import com.braintrustdata.api.models.ProjectLogFetchPostParams.ProjectLogFetchPostBody class ProjectLogFetchPostParamsTest { @Test fun createProjectLogFetchPostParams() { - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() + ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() } @Test fun getBody() { - val params = - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.cursor()).isEqualTo("cursor") - assertThat(body.filters()) - .isEqualTo( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - assertThat(body.limit()).isEqualTo(123L) - assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") - assertThat(body.maxXactId()).isEqualTo("max_xact_id") - assertThat(body.version()).isEqualTo("version") + val params = ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.cursor()).isEqualTo("cursor") + assertThat(body.filters()).isEqualTo(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + assertThat(body.limit()).isEqualTo(123L) + assertThat(body.maxRootSpanId()).isEqualTo("max_root_span_id") + assertThat(body.maxXactId()).isEqualTo("max_xact_id") + assertThat(body.version()).isEqualTo("version") } @Test fun getBodyWithoutOptionalFields() { - val params = - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponseTest.kt deleted file mode 100755 index fc55624c..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchPostResponseTest.kt +++ /dev/null @@ -1,106 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectLogFetchPostResponseTest { - - @Test - fun createProjectLogFetchPostResponse() { - val projectLogFetchPostResponse = - ProjectLogFetchPostResponse.builder() - .events( - listOf( - ProjectLogFetchPostResponse.Event.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogFetchPostResponse.Event.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .context( - ProjectLogFetchPostResponse.Event.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ProjectLogFetchPostResponse.Event.Metadata.builder().build()) - .metrics( - ProjectLogFetchPostResponse.Event.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogFetchPostResponse.Event.Scores.builder().build()) - .spanAttributes( - ProjectLogFetchPostResponse.Event.SpanAttributes.builder() - .name("name") - .type(ProjectLogFetchPostResponse.Event.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - ) - .cursor("cursor") - .build() - assertThat(projectLogFetchPostResponse).isNotNull - assertThat(projectLogFetchPostResponse.events()) - .containsExactly( - ProjectLogFetchPostResponse.Event.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogFetchPostResponse.Event.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .context( - ProjectLogFetchPostResponse.Event.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ProjectLogFetchPostResponse.Event.Metadata.builder().build()) - .metrics( - ProjectLogFetchPostResponse.Event.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogFetchPostResponse.Event.Scores.builder().build()) - .spanAttributes( - ProjectLogFetchPostResponse.Event.SpanAttributes.builder() - .name("name") - .type(ProjectLogFetchPostResponse.Event.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - assertThat(projectLogFetchPostResponse.cursor()).isEqualTo("cursor") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponseTest.kt deleted file mode 100755 index 27c87fef..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogFetchResponseTest.kt +++ /dev/null @@ -1,106 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import com.braintrustdata.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectLogFetchResponseTest { - - @Test - fun createProjectLogFetchResponse() { - val projectLogFetchResponse = - ProjectLogFetchResponse.builder() - .events( - listOf( - ProjectLogFetchResponse.Event.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogFetchResponse.Event.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .context( - ProjectLogFetchResponse.Event.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ProjectLogFetchResponse.Event.Metadata.builder().build()) - .metrics( - ProjectLogFetchResponse.Event.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogFetchResponse.Event.Scores.builder().build()) - .spanAttributes( - ProjectLogFetchResponse.Event.SpanAttributes.builder() - .name("name") - .type(ProjectLogFetchResponse.Event.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - ) - .cursor("cursor") - .build() - assertThat(projectLogFetchResponse).isNotNull - assertThat(projectLogFetchResponse.events()) - .containsExactly( - ProjectLogFetchResponse.Event.builder() - .id("id") - ._xactId("_xact_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .logId(ProjectLogFetchResponse.Event.LogId.G) - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .rootSpanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .spanId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .context( - ProjectLogFetchResponse.Event.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ProjectLogFetchResponse.Event.Metadata.builder().build()) - .metrics( - ProjectLogFetchResponse.Event.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogFetchResponse.Event.Scores.builder().build()) - .spanAttributes( - ProjectLogFetchResponse.Event.SpanAttributes.builder() - .name("name") - .type(ProjectLogFetchResponse.Event.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("string")) - .build() - ) - assertThat(projectLogFetchResponse.cursor()).isEqualTo("cursor") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt index 9c5729d1..d55253d1 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertParamsTest.kt @@ -2,200 +2,151 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.models.* +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectLogInsertParams +import com.braintrustdata.api.models.ProjectLogInsertParams.ProjectLogInsertBody class ProjectLogInsertParamsTest { @Test fun createProjectLogInsertParams() { - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() + ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) + .metrics(InsertProjectLogsEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) + .spanAttributes(InsertProjectLogsEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build()))) + .build() } @Test fun getBody() { - val params = - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) + val params = ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) + .metrics(InsertProjectLogsEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) + .spanAttributes(InsertProjectLogsEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build()))) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()).isEqualTo(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) + .metrics(InsertProjectLogsEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) + .spanAttributes(InsertProjectLogsEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build()))) } @Test fun getBodyWithoutOptionalFields() { - val params = - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder().build() - ) - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.events()) - .isEqualTo( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder().build() - ) - ) - ) + val params = ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(InsertProjectLogsEventReplace.builder().build()))) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.events()).isEqualTo(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(InsertProjectLogsEventReplace.builder().build()))) } @Test fun getPathParam() { - val params = - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.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") + .events(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(InsertProjectLogsEventReplace.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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponseTest.kt deleted file mode 100755 index c505360d..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogInsertResponseTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectLogInsertResponseTest { - - @Test - fun createProjectLogInsertResponse() { - val projectLogInsertResponse = - ProjectLogInsertResponse.builder().rowIds(listOf("string")).build() - assertThat(projectLogInsertResponse).isNotNull - assertThat(projectLogInsertResponse.rowIds()).containsExactly("string") - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt index 962947f8..482bc4f1 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectLogsEventTest.kt @@ -2,99 +2,87 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ProjectLogsEvent 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(123L) - .build() - ) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(ProjectLogsEvent.Metadata.builder().build()) - .metrics( - ProjectLogsEvent.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(ProjectLogsEvent.Scores.builder().build()) - .spanAttributes( - ProjectLogsEvent.SpanAttributes.builder() - .name("name") - .type(ProjectLogsEvent.SpanAttributes.Type.LLM) - .build() - ) - .spanParents(listOf("string")) - .tags(listOf("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()) - .isEqualTo( - ProjectLogsEvent.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - assertThat(projectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent.metadata()) - .isEqualTo(ProjectLogsEvent.Metadata.builder().build()) - assertThat(projectLogsEvent.metrics()) - .isEqualTo( - ProjectLogsEvent.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) - assertThat(projectLogsEvent.scores()).isEqualTo(ProjectLogsEvent.Scores.builder().build()) - assertThat(projectLogsEvent.spanAttributes()) - .isEqualTo( - ProjectLogsEvent.SpanAttributes.builder() - .name("name") - .type(ProjectLogsEvent.SpanAttributes.Type.LLM) - .build() - ) - assertThat(projectLogsEvent.spanParents()).containsExactly("string") - assertThat(projectLogsEvent.tags()).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(123L) + .build()) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(ProjectLogsEvent.Metadata.builder().build()) + .metrics(ProjectLogsEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(ProjectLogsEvent.Scores.builder().build()) + .spanAttributes(ProjectLogsEvent.SpanAttributes.builder() + .name("name") + .type(ProjectLogsEvent.SpanAttributes.Type.LLM) + .build()) + .spanParents(listOf("string")) + .tags(listOf("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()).isEqualTo(ProjectLogsEvent.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + assertThat(projectLogsEvent._error()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._expected()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent._input()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.metadata()).isEqualTo(ProjectLogsEvent.Metadata.builder().build()) + assertThat(projectLogsEvent.metrics()).isEqualTo(ProjectLogsEvent.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + assertThat(projectLogsEvent._output()).isEqualTo(JsonValue.from(mapOf())) + assertThat(projectLogsEvent.scores()).isEqualTo(ProjectLogsEvent.Scores.builder().build()) + assertThat(projectLogsEvent.spanAttributes()).isEqualTo(ProjectLogsEvent.SpanAttributes.builder() + .name("name") + .type(ProjectLogsEvent.SpanAttributes.Type.LLM) + .build()) + assertThat(projectLogsEvent.spanParents()).containsExactly("string") + assertThat(projectLogsEvent.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt index 231a1864..26b20bbe 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectRetrieveParamsTest.kt @@ -2,27 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectRetrieveParams class ProjectRetrieveParamsTest { @Test fun createProjectRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt index a190a270..66a8793e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCategoryTest.kt @@ -2,16 +2,27 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ProjectScoreCategory class ProjectScoreCategoryTest { @Test fun createProjectScoreCategory() { - val projectScoreCategory = ProjectScoreCategory.builder().name("name").value(42.23).build() - assertThat(projectScoreCategory).isNotNull - assertThat(projectScoreCategory.name()).isEqualTo("name") - assertThat(projectScoreCategory.value()).isEqualTo(42.23) + val projectScoreCategory = ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build() + assertThat(projectScoreCategory).isNotNull + assertThat(projectScoreCategory.name()).isEqualTo("name") + assertThat(projectScoreCategory.value()).isEqualTo(42.23) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt index 8fabf12d..f947db3e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreCreateParamsTest.kt @@ -2,65 +2,71 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectScoreCreateParams +import com.braintrustdata.api.models.ProjectScoreCreateParams.ProjectScoreCreateBody class ProjectScoreCreateParamsTest { @Test fun createProjectScoreCreateParams() { - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categories( - ProjectScoreCreateParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .build() + ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categories(ProjectScoreCreateParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + .description("description") + .build() } @Test fun getBody() { - val params = - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categories( - ProjectScoreCreateParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) - assertThat(body.categories()) - .isEqualTo( - ProjectScoreCreateParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - assertThat(body.description()).isEqualTo("description") + val params = ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categories(ProjectScoreCreateParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + .description("description") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreCreateParams.ScoreType.SLIDER) + assertThat(body.categories()).isEqualTo(ProjectScoreCreateParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + assertThat(body.description()).isEqualTo("description") } @Test fun getBodyWithoutOptionalFields() { - val params = - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt index 896f79a5..e492ca40 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreDeleteParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectScoreDeleteParams class ProjectScoreDeleteParamsTest { @Test fun createProjectScoreDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt index 6cfb65c9..c360e52f 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreListParamsTest.kt @@ -2,80 +2,68 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectScoreListParams class ProjectScoreListParamsTest { @Test fun createProjectScoreListParams() { - ProjectScoreListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectScoreName("project_score_name") - .scoreType( - ProjectScoreListParams.ScoreType.ofUnionMember0( - ProjectScoreListParams.ScoreType.UnionMember0.SLIDER - ) - ) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + ProjectScoreListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectScoreName("project_score_name") + .scoreType(ProjectScoreListParams.ScoreType.ofUnionMember0(ProjectScoreListParams.ScoreType.UnionMember0.SLIDER)) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - ProjectScoreListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectName("project_name") - .projectScoreName("project_score_name") - .scoreType( - ProjectScoreListParams.ScoreType.ofUnionMember0( - ProjectScoreListParams.ScoreType.UnionMember0.SLIDER - ) - ) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf( - ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .toString() - ) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("project_score_name", listOf("project_score_name")) - expected.put( - "score_type", - listOf( - ProjectScoreListParams.ScoreType.ofUnionMember0( - ProjectScoreListParams.UnionMember0.SLIDER.toString() - ) - .toString() - ) - ) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ProjectScoreListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectName("project_name") + .projectScoreName("project_score_name") + .scoreType(ProjectScoreListParams.ScoreType.ofUnionMember0(ProjectScoreListParams.ScoreType.UnionMember0.SLIDER)) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(ProjectScoreListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("project_name", listOf("project_name")) + expected.put("project_score_name", listOf("project_score_name")) + expected.put("score_type", listOf(ProjectScoreListParams.ScoreType.ofUnionMember0(ProjectScoreListParams.UnionMember0.SLIDER.toString()).toString())) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = ProjectScoreListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ProjectScoreListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt index 24c4cf5d..817be0d6 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreReplaceParamsTest.kt @@ -2,65 +2,71 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectScoreReplaceParams +import com.braintrustdata.api.models.ProjectScoreReplaceParams.ProjectScoreReplaceBody class ProjectScoreReplaceParamsTest { @Test fun createProjectScoreReplaceParams() { - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categories( - ProjectScoreReplaceParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .build() + ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categories(ProjectScoreReplaceParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + .description("description") + .build() } @Test fun getBody() { - val params = - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categories( - ProjectScoreReplaceParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) - assertThat(body.categories()) - .isEqualTo( - ProjectScoreReplaceParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - assertThat(body.description()).isEqualTo("description") + val params = ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categories(ProjectScoreReplaceParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + .description("description") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.scoreType()).isEqualTo(ProjectScoreReplaceParams.ScoreType.SLIDER) + assertThat(body.categories()).isEqualTo(ProjectScoreReplaceParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + assertThat(body.description()).isEqualTo("description") } @Test fun getBodyWithoutOptionalFields() { - val params = - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt index 9237a10b..6246e7cd 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreRetrieveParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectScoreRetrieveParams class ProjectScoreRetrieveParamsTest { @Test fun createProjectScoreRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt index e13a2677..bb6b9531 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreTest.kt @@ -2,98 +2,73 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ProjectScore 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") - .categories( - ProjectScore.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .config( - ProjectScore.Config.builder() - .destination(ProjectScore.Config.Destination.EXPECTED) - .multiSelect(true) - .online( - ProjectScore.Config.Online.builder() - .samplingRate(1.0) - .scorers( - listOf( - ProjectScore.Config.Online.Scorer.ofFunction( - ProjectScore.Config.Online.Scorer.Function.builder() - .id("id") - .type( - ProjectScore.Config.Online.Scorer.Function.Type - .FUNCTION - ) - .build() - ) - ) - ) - .applyToRootSpan(true) - .applyToSpanNames(listOf("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()) - .isEqualTo( - ProjectScore.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - assertThat(projectScore.config()) - .isEqualTo( - ProjectScore.Config.builder() - .destination(ProjectScore.Config.Destination.EXPECTED) - .multiSelect(true) - .online( - ProjectScore.Config.Online.builder() - .samplingRate(1.0) - .scorers( - listOf( - ProjectScore.Config.Online.Scorer.ofFunction( - ProjectScore.Config.Online.Scorer.Function.builder() - .id("id") - .type( - ProjectScore.Config.Online.Scorer.Function.Type - .FUNCTION - ) - .build() - ) - ) - ) - .applyToRootSpan(true) - .applyToSpanNames(listOf("string")) - .build() - ) - .build() - ) - assertThat(projectScore.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectScore.description()).isEqualTo("description") - assertThat(projectScore.position()).isEqualTo("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") + .categories(ProjectScore.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + .config(ProjectScore.Config.builder() + .destination(ProjectScore.Config.Destination.EXPECTED) + .multiSelect(true) + .online(ProjectScore.Config.Online.builder() + .samplingRate(1.0) + .scorers(listOf(ProjectScore.Config.Online.Scorer.ofFunction(ProjectScore.Config.Online.Scorer.Function.builder() + .id("id") + .type(ProjectScore.Config.Online.Scorer.Function.Type.FUNCTION) + .build()))) + .applyToRootSpan(true) + .applyToSpanNames(listOf("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()).isEqualTo(ProjectScore.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + assertThat(projectScore.config()).isEqualTo(ProjectScore.Config.builder() + .destination(ProjectScore.Config.Destination.EXPECTED) + .multiSelect(true) + .online(ProjectScore.Config.Online.builder() + .samplingRate(1.0) + .scorers(listOf(ProjectScore.Config.Online.Scorer.ofFunction(ProjectScore.Config.Online.Scorer.Function.builder() + .id("id") + .type(ProjectScore.Config.Online.Scorer.Function.Type.FUNCTION) + .build()))) + .applyToRootSpan(true) + .applyToSpanNames(listOf("string")) + .build()) + .build()) + assertThat(projectScore.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectScore.description()).isEqualTo("description") + assertThat(projectScore.position()).isEqualTo("position") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt index 47ebd150..20dd07e6 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectScoreUpdateParamsTest.kt @@ -2,74 +2,79 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectScoreUpdateParams +import com.braintrustdata.api.models.ProjectScoreUpdateParams.ProjectScoreUpdateBody class ProjectScoreUpdateParamsTest { @Test fun createProjectScoreUpdateParams() { - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categories( - ProjectScoreUpdateParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() + ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categories(ProjectScoreUpdateParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() } @Test fun getBody() { - val params = - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categories( - ProjectScoreUpdateParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.categories()) - .isEqualTo( - ProjectScoreUpdateParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") - assertThat(body.scoreType()).isEqualTo(ProjectScoreUpdateParams.ScoreType.SLIDER) + val params = ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categories(ProjectScoreUpdateParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.categories()).isEqualTo(ProjectScoreUpdateParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + assertThat(body.description()).isEqualTo("description") + assertThat(body.name()).isEqualTo("name") + assertThat(body.scoreType()).isEqualTo(ProjectScoreUpdateParams.ScoreType.SLIDER) } @Test fun getBodyWithoutOptionalFields() { - val params = - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt index 111ab845..72b372bf 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagCreateParamsTest.kt @@ -2,49 +2,59 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectTagCreateParams +import com.braintrustdata.api.models.ProjectTagCreateParams.ProjectTagCreateBody class ProjectTagCreateParamsTest { @Test fun createProjectTagCreateParams() { - 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 getBody() { - val params = - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.color()).isEqualTo("color") - assertThat(body.description()).isEqualTo("description") + val params = ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.color()).isEqualTo("color") + assertThat(body.description()).isEqualTo("description") } @Test fun getBodyWithoutOptionalFields() { - val params = - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt index 12369e03..d3cfde17 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagDeleteParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectTagDeleteParams class ProjectTagDeleteParamsTest { @Test fun createProjectTagDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt index 091272bb..24726cc1 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagListParamsTest.kt @@ -2,60 +2,65 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectTagListParams class ProjectTagListParamsTest { @Test fun createProjectTagListParams() { - ProjectTagListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .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(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .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 getQueryParams() { - val params = - ProjectTagListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .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 = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf( - ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString() - ) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("project_tag_name", listOf("project_tag_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ProjectTagListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .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 = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(ProjectTagListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("project_name", listOf("project_name")) + expected.put("project_tag_name", listOf("project_tag_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = ProjectTagListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ProjectTagListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt index bec95fa1..df623ed7 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagReplaceParamsTest.kt @@ -2,49 +2,59 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectTagReplaceParams +import com.braintrustdata.api.models.ProjectTagReplaceParams.ProjectTagReplaceBody class ProjectTagReplaceParamsTest { @Test fun createProjectTagReplaceParams() { - 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 getBody() { - val params = - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.color()).isEqualTo("color") - assertThat(body.description()).isEqualTo("description") + val params = ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.color()).isEqualTo("color") + assertThat(body.description()).isEqualTo("description") } @Test fun getBodyWithoutOptionalFields() { - val params = - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt index cd792595..96d309ad 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagRetrieveParamsTest.kt @@ -2,29 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectTagRetrieveParams class ProjectTagRetrieveParamsTest { @Test fun createProjectTagRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt index 188c5d3e..23269e3b 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagTest.kt @@ -2,31 +2,37 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ProjectTag 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()).isEqualTo("color") - assertThat(projectTag.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(projectTag.description()).isEqualTo("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()).isEqualTo("color") + assertThat(projectTag.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(projectTag.description()).isEqualTo("description") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt index 9b5ac6a1..9588d742 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTagUpdateParamsTest.kt @@ -2,58 +2,67 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectTagUpdateParams +import com.braintrustdata.api.models.ProjectTagUpdateParams.ProjectTagUpdateBody class ProjectTagUpdateParamsTest { @Test fun createProjectTagUpdateParams() { - 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 getBody() { - val params = - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.color()).isEqualTo("color") - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") + val params = ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.color()).isEqualTo("color") + assertThat(body.description()).isEqualTo("description") + assertThat(body.name()).isEqualTo("name") } @Test fun getBodyWithoutOptionalFields() { - val params = - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull + val params = ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt index 7403efd6..89a08c3a 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectTest.kt @@ -2,32 +2,41 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.Project 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(Project.Settings.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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(project.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(project.settings()) - .isEqualTo(Project.Settings.builder().comparisonKey("comparison_key").build()) - assertThat(project.userId()).isEqualTo("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(Project.Settings.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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(project.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(project.settings()).isEqualTo(Project.Settings.builder() + .comparisonKey("comparison_key") + .build()) + assertThat(project.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt index a224eab1..0e2baf38 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ProjectUpdateParamsTest.kt @@ -2,58 +2,70 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ProjectUpdateParams +import com.braintrustdata.api.models.ProjectUpdateParams.ProjectUpdateBody class ProjectUpdateParamsTest { @Test fun createProjectUpdateParams() { - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings( - ProjectUpdateParams.Settings.builder().comparisonKey("comparison_key").build() - ) - .build() + ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectUpdateParams.Settings.builder() + .comparisonKey("comparison_key") + .build()) + .build() } @Test fun getBody() { - val params = - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings( - ProjectUpdateParams.Settings.builder().comparisonKey("comparison_key").build() - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.settings()) - .isEqualTo( - ProjectUpdateParams.Settings.builder().comparisonKey("comparison_key").build() - ) + val params = ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectUpdateParams.Settings.builder() + .comparisonKey("comparison_key") + .build()) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.settings()).isEqualTo(ProjectUpdateParams.Settings.builder() + .comparisonKey("comparison_key") + .build()) } @Test fun getBodyWithoutOptionalFields() { - val params = - ProjectUpdateParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() - assertThat(body).isNotNull + val params = ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt index 731eec6b..b8455c29 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptCreateParamsTest.kt @@ -2,288 +2,172 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.PromptCreateParams +import com.braintrustdata.api.models.PromptCreateParams.PromptCreateBody class PromptCreateParamsTest { @Test fun createPromptCreateParams() { - PromptCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(PromptCreateParams.FunctionType.TASK) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() + PromptCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(PromptCreateParams.FunctionType.TASK) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build() } @Test fun getBody() { - val params = - PromptCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(PromptCreateParams.FunctionType.TASK) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") - assertThat(body.description()).isEqualTo("description") - assertThat(body.functionType()).isEqualTo(PromptCreateParams.FunctionType.TASK) - assertThat(body.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(body.tags()).isEqualTo(listOf("string")) + val params = PromptCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(PromptCreateParams.FunctionType.TASK) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") + assertThat(body.description()).isEqualTo("description") + assertThat(body.functionType()).isEqualTo(PromptCreateParams.FunctionType.TASK) + assertThat(body.promptData()).isEqualTo(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + assertThat(body.tags()).isEqualTo(listOf("string")) } @Test fun getBodyWithoutOptionalFields() { - val params = - PromptCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + val params = PromptCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt index 2a4f60c0..d0b996d6 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptDataTest.kt @@ -2,157 +2,89 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.PromptData class PromptDataTest { @Test fun createPromptData() { - val promptData = - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams.ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - assertThat(promptData).isNotNull - assertThat(promptData.options()) - .isEqualTo( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams.ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto( - PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - assertThat(promptData.origin()) - .isEqualTo( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - assertThat(promptData.parser()) - .isEqualTo( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - assertThat(promptData.prompt()) - .isEqualTo( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) + val promptData = PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build() + assertThat(promptData).isNotNull + assertThat(promptData.options()).isEqualTo(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + assertThat(promptData.origin()).isEqualTo(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + assertThat(promptData.parser()).isEqualTo(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + assertThat(promptData.prompt()).isEqualTo(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt index a819f9d2..8623039d 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptDeleteParamsTest.kt @@ -2,25 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.PromptDeleteParams class PromptDeleteParamsTest { @Test fun createPromptDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt index a2c57163..e1e2e686 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptListParamsTest.kt @@ -2,64 +2,71 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.PromptListParams class PromptListParamsTest { @Test fun createPromptListParams() { - PromptListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .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(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .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 getQueryParams() { - val params = - PromptListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .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 = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("project_name", listOf("project_name")) - expected.put("prompt_name", listOf("prompt_name")) - expected.put("slug", listOf("slug")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("version", listOf("version")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = PromptListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .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 = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(PromptListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("project_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("project_name", listOf("project_name")) + expected.put("prompt_name", listOf("prompt_name")) + expected.put("slug", listOf("slug")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("version", listOf("version")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = PromptListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = PromptListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt index 57fcf3b2..34b104d8 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptReplaceParamsTest.kt @@ -2,288 +2,172 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.PromptReplaceParams +import com.braintrustdata.api.models.PromptReplaceParams.PromptReplaceBody class PromptReplaceParamsTest { @Test fun createPromptReplaceParams() { - PromptReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(PromptReplaceParams.FunctionType.TASK) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() + PromptReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(PromptReplaceParams.FunctionType.TASK) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build() } @Test fun getBody() { - val params = - PromptReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(PromptReplaceParams.FunctionType.TASK) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") - assertThat(body.description()).isEqualTo("description") - assertThat(body.functionType()).isEqualTo(PromptReplaceParams.FunctionType.TASK) - assertThat(body.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(body.tags()).isEqualTo(listOf("string")) + val params = PromptReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(PromptReplaceParams.FunctionType.TASK) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") + assertThat(body.description()).isEqualTo("description") + assertThat(body.functionType()).isEqualTo(PromptReplaceParams.FunctionType.TASK) + assertThat(body.promptData()).isEqualTo(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + assertThat(body.tags()).isEqualTo(listOf("string")) } @Test fun getBodyWithoutOptionalFields() { - val params = - PromptReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.slug()).isEqualTo("slug") + val params = PromptReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.projectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.slug()).isEqualTo("slug") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt index d8aa5099..34040a7a 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptRetrieveParamsTest.kt @@ -2,25 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.PromptRetrieveParams class PromptRetrieveParamsTest { @Test fun createPromptRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt index bc647288..06412399 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptTest.kt @@ -2,196 +2,117 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.Prompt 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.TASK) - .metadata(Prompt.Metadata.builder().build()) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(prompt.description()).isEqualTo("description") - assertThat(prompt.functionType()).isEqualTo(Prompt.FunctionType.TASK) - assertThat(prompt.metadata()).isEqualTo(Prompt.Metadata.builder().build()) - assertThat(prompt.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(prompt.tags()).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.TASK) + .metadata(Prompt.Metadata.builder().build()) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(prompt.description()).isEqualTo("description") + assertThat(prompt.functionType()).isEqualTo(Prompt.FunctionType.TASK) + assertThat(prompt.metadata()).isEqualTo(Prompt.Metadata.builder().build()) + assertThat(prompt.promptData()).isEqualTo(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + assertThat(prompt.tags()).containsExactly("string") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt index f649bc32..6e86d41e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/PromptUpdateParamsTest.kt @@ -2,288 +2,175 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.PromptUpdateParams +import com.braintrustdata.api.models.PromptUpdateParams.PromptUpdateBody class PromptUpdateParamsTest { @Test fun createPromptUpdateParams() { - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .slug("slug") - .tags(listOf("string")) - .build() + PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .slug("slug") + .tags(listOf("string")) + .build() } @Test fun getBody() { - val params = - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .slug("slug") - .tags(listOf("string")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") - assertThat(body.promptData()) - .isEqualTo( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams.FunctionCall - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams.ToolChoice - .ofAuto( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - assertThat(body.slug()).isEqualTo("slug") - assertThat(body.tags()).isEqualTo(listOf("string")) + val params = PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .slug("slug") + .tags(listOf("string")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.description()).isEqualTo("description") + assertThat(body.name()).isEqualTo("name") + assertThat(body.promptData()).isEqualTo(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + assertThat(body.slug()).isEqualTo("slug") + assertThat(body.tags()).isEqualTo(listOf("string")) } @Test fun getBodyWithoutOptionalFields() { - val params = - PromptUpdateParams.builder().promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() - assertThat(body).isNotNull + val params = PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt index 2473839f..f0ce87d5 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RepoInfoTest.kt @@ -2,34 +2,41 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.RepoInfo 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()).isEqualTo("author_email") - assertThat(repoInfo.authorName()).isEqualTo("author_name") - assertThat(repoInfo.branch()).isEqualTo("branch") - assertThat(repoInfo.commit()).isEqualTo("commit") - assertThat(repoInfo.commitMessage()).isEqualTo("commit_message") - assertThat(repoInfo.commitTime()).isEqualTo("commit_time") - assertThat(repoInfo.dirty()).isEqualTo(true) - assertThat(repoInfo.gitDiff()).isEqualTo("git_diff") - assertThat(repoInfo.tag()).isEqualTo("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()).isEqualTo("author_email") + assertThat(repoInfo.authorName()).isEqualTo("author_name") + assertThat(repoInfo.branch()).isEqualTo("branch") + assertThat(repoInfo.commit()).isEqualTo("commit") + assertThat(repoInfo.commitMessage()).isEqualTo("commit_message") + assertThat(repoInfo.commitTime()).isEqualTo("commit_time") + assertThat(repoInfo.dirty()).isEqualTo(true) + assertThat(repoInfo.gitDiff()).isEqualTo("git_diff") + assertThat(repoInfo.tag()).isEqualTo("tag") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt index e4500a98..795f66b9 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleCreateParamsTest.kt @@ -2,75 +2,69 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.RoleCreateParams +import com.braintrustdata.api.models.RoleCreateParams.RoleCreateBody class RoleCreateParamsTest { @Test fun createRoleCreateParams() { - RoleCreateParams.builder() - .name("name") - .description("description") - .memberPermissions( - listOf( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() + RoleCreateParams.builder() + .name("name") + .description("description") + .memberPermissions(listOf(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() } @Test fun getBody() { - val params = - RoleCreateParams.builder() - .name("name") - .description("description") - .memberPermissions( - listOf( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).isEqualTo("description") - assertThat(body.memberPermissions()) - .isEqualTo( - listOf( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.memberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + val params = RoleCreateParams.builder() + .name("name") + .description("description") + .memberPermissions(listOf(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).isEqualTo("description") + assertThat(body.memberPermissions()).isEqualTo(listOf(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.memberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = RoleCreateParams.builder().name("name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = RoleCreateParams.builder() + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt index df2e651a..5c7dce9a 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleDeleteParamsTest.kt @@ -2,25 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.RoleDeleteParams class RoleDeleteParamsTest { @Test fun createRoleDeleteParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt index 2db9679b..07eceb0b 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleListParamsTest.kt @@ -2,52 +2,59 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.RoleListParams class RoleListParamsTest { @Test fun createRoleListParams() { - RoleListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .roleName("role_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + RoleListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .roleName("role_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - RoleListParams.builder() - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .roleName("role_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("role_name", listOf("role_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = RoleListParams.builder() + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .roleName("role_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(RoleListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("role_name", listOf("role_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = RoleListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = RoleListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt index 299ccd32..08305d3f 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleReplaceParamsTest.kt @@ -2,75 +2,69 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.RoleReplaceParams +import com.braintrustdata.api.models.RoleReplaceParams.RoleReplaceBody class RoleReplaceParamsTest { @Test fun createRoleReplaceParams() { - RoleReplaceParams.builder() - .name("name") - .description("description") - .memberPermissions( - listOf( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() + RoleReplaceParams.builder() + .name("name") + .description("description") + .memberPermissions(listOf(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() } @Test fun getBody() { - val params = - RoleReplaceParams.builder() - .name("name") - .description("description") - .memberPermissions( - listOf( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.description()).isEqualTo("description") - assertThat(body.memberPermissions()) - .isEqualTo( - listOf( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.memberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.orgName()).isEqualTo("org_name") + val params = RoleReplaceParams.builder() + .name("name") + .description("description") + .memberPermissions(listOf(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.description()).isEqualTo("description") + assertThat(body.memberPermissions()).isEqualTo(listOf(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.memberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.orgName()).isEqualTo("org_name") } @Test fun getBodyWithoutOptionalFields() { - val params = RoleReplaceParams.builder().name("name").build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") + val params = RoleReplaceParams.builder() + .name("name") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt index d0791c4d..de7ef2ce 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleRetrieveParamsTest.kt @@ -2,25 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.RoleRetrieveParams class RoleRetrieveParamsTest { @Test fun createRoleRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt index 758a8e07..a427810e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleTest.kt @@ -2,50 +2,47 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.Role 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") - .memberPermissions( - listOf( - Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType( - Role.MemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .memberRoles(listOf("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(role.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(role.description()).isEqualTo("description") - assertThat(role.memberPermissions()) - .containsExactly( - Role.MemberPermission.builder() - .permission(Role.MemberPermission.Permission.CREATE) - .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) - .build() - ) - assertThat(role.memberRoles()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(role.userId()).isEqualTo("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") + .memberPermissions(listOf(Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .memberRoles(listOf("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()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(role.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(role.description()).isEqualTo("description") + assertThat(role.memberPermissions()).containsExactly(Role.MemberPermission.builder() + .permission(Role.MemberPermission.Permission.CREATE) + .restrictObjectType(Role.MemberPermission.RestrictObjectType.ORGANIZATION) + .build()) + assertThat(role.memberRoles()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.orgId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(role.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt index 46274c48..260c271c 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/RoleUpdateParamsTest.kt @@ -2,121 +2,94 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.RoleUpdateParams +import com.braintrustdata.api.models.RoleUpdateParams.RoleUpdateBody class RoleUpdateParamsTest { @Test fun createRoleUpdateParams() { - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberPermissions( - listOf( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberPermissions( - listOf( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() + RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberPermissions(listOf(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberPermissions(listOf(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() } @Test fun getBody() { - val params = - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberPermissions( - listOf( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberPermissions( - listOf( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) - ) - .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.addMemberPermissions()) - .isEqualTo( - listOf( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.addMemberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(body.description()).isEqualTo("description") - assertThat(body.name()).isEqualTo("name") - assertThat(body.removeMemberPermissions()) - .isEqualTo( - listOf( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION - ) - .build() - ) - ) - assertThat(body.removeMemberRoles()) - .isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + val params = RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberPermissions(listOf(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberPermissions(listOf(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.addMemberPermissions()).isEqualTo(listOf(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.addMemberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(body.description()).isEqualTo("description") + assertThat(body.name()).isEqualTo("name") + assertThat(body.removeMemberPermissions()).isEqualTo(listOf(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + assertThat(body.removeMemberRoles()).isEqualTo(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) } @Test fun getBodyWithoutOptionalFields() { - val params = - RoleUpdateParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val body = params.getBody() - assertThat(body).isNotNull + val params = RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull } @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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt index ff4f5a7d..b8cbe653 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ScoreSummaryTest.kt @@ -2,26 +2,33 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ScoreSummary class ScoreSummaryTest { @Test fun createScoreSummary() { - val scoreSummary = - ScoreSummary.builder() - .improvements(123L) - .name("name") - .regressions(123L) - .score(1.0) - .diff(1.0) - .build() - assertThat(scoreSummary).isNotNull - assertThat(scoreSummary.improvements()).isEqualTo(123L) - assertThat(scoreSummary.name()).isEqualTo("name") - assertThat(scoreSummary.regressions()).isEqualTo(123L) - assertThat(scoreSummary.score()).isEqualTo(1.0) - assertThat(scoreSummary.diff()).isEqualTo(1.0) + val scoreSummary = ScoreSummary.builder() + .improvements(123L) + .name("name") + .regressions(123L) + .score(1.0) + .diff(1.0) + .build() + assertThat(scoreSummary).isNotNull + assertThat(scoreSummary.improvements()).isEqualTo(123L) + assertThat(scoreSummary.name()).isEqualTo("name") + assertThat(scoreSummary.regressions()).isEqualTo(123L) + assertThat(scoreSummary.score()).isEqualTo(1.0) + assertThat(scoreSummary.diff()).isEqualTo(1.0) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt index fb1ee33d..dfe563ac 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeDatasetResponseTest.kt @@ -2,27 +2,37 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.SummarizeDatasetResponse 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(123L).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()) - .isEqualTo(DataSummary.builder().totalRecords(123L).build()) + val summarizeDatasetResponse = SummarizeDatasetResponse.builder() + .datasetName("dataset_name") + .datasetUrl("https://example.com") + .projectName("project_name") + .projectUrl("https://example.com") + .dataSummary(DataSummary.builder() + .totalRecords(123L) + .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()).isEqualTo(DataSummary.builder() + .totalRecords(123L) + .build()) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt index a26cf800..c8479048 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/SummarizeExperimentResponseTest.kt @@ -2,33 +2,37 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.SummarizeExperimentResponse 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().build()) - .scores(SummarizeExperimentResponse.Scores.builder().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()) - .isEqualTo("comparison_experiment_name") - assertThat(summarizeExperimentResponse.metrics()) - .isEqualTo(SummarizeExperimentResponse.Metrics.builder().build()) - assertThat(summarizeExperimentResponse.scores()) - .isEqualTo(SummarizeExperimentResponse.Scores.builder().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().build()) + .scores(SummarizeExperimentResponse.Scores.builder().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()).isEqualTo("comparison_experiment_name") + assertThat(summarizeExperimentResponse.metrics()).isEqualTo(SummarizeExperimentResponse.Metrics.builder().build()) + assertThat(summarizeExperimentResponse.scores()).isEqualTo(SummarizeExperimentResponse.Scores.builder().build()) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt index b059ced3..71f6a83c 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/TopLevelHelloWorldParamsTest.kt @@ -2,13 +2,25 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.TopLevelHelloWorldParams class TopLevelHelloWorldParamsTest { @Test fun createTopLevelHelloWorldParams() { - TopLevelHelloWorldParams.builder().build() + TopLevelHelloWorldParams.builder().build() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt index 45d5d6ce..0d1f5a38 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserListParamsTest.kt @@ -2,58 +2,65 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.UserListParams class UserListParamsTest { @Test fun createUserListParams() { - UserListParams.builder() - .email(UserListParams.Email.ofString("string")) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName(UserListParams.FamilyName.ofString("string")) - .givenName(UserListParams.GivenName.ofString("string")) - .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + UserListParams.builder() + .email(UserListParams.Email.ofString("string")) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .familyName(UserListParams.FamilyName.ofString("string")) + .givenName(UserListParams.GivenName.ofString("string")) + .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() } @Test fun getQueryParams() { - val params = - UserListParams.builder() - .email(UserListParams.Email.ofString("string")) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .familyName(UserListParams.FamilyName.ofString("string")) - .givenName(UserListParams.GivenName.ofString("string")) - .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .orgName("org_name") - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("email", listOf(UserListParams.Email.ofString("string").toString())) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("family_name", listOf(UserListParams.FamilyName.ofString("string").toString())) - expected.put("given_name", listOf(UserListParams.GivenName.ofString("string").toString())) - expected.put( - "ids", - listOf(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - ) - expected.put("limit", listOf("123")) - expected.put("org_name", listOf("org_name")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = UserListParams.builder() + .email(UserListParams.Email.ofString("string")) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .familyName(UserListParams.FamilyName.ofString("string")) + .givenName(UserListParams.GivenName.ofString("string")) + .ids(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .orgName("org_name") + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("email", listOf(UserListParams.Email.ofString("string").toString())) + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("family_name", listOf(UserListParams.FamilyName.ofString("string").toString())) + expected.put("given_name", listOf(UserListParams.GivenName.ofString("string").toString())) + expected.put("ids", listOf(UserListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("org_name", listOf("org_name")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = UserListParams.builder().build() - val expected = mutableMapOf>() - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = UserListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt index ee03a0d3..bb485d82 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserRetrieveParamsTest.kt @@ -2,25 +2,39 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.UserRetrieveParams class UserRetrieveParamsTest { @Test fun createUserRetrieveParams() { - 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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt index f7c71792..0e017df6 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/UserTest.kt @@ -2,29 +2,35 @@ package com.braintrustdata.api.models +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.User 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()).isEqualTo("avatar_url") - assertThat(user.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(user.email()).isEqualTo("email") - assertThat(user.familyName()).isEqualTo("family_name") - assertThat(user.givenName()).isEqualTo("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()).isEqualTo("avatar_url") + assertThat(user.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(user.email()).isEqualTo("email") + assertThat(user.familyName()).isEqualTo("family_name") + assertThat(user.givenName()).isEqualTo("given_name") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt index d06eabc6..20afe4ef 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewCreateParamsTest.kt @@ -2,116 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.models.* +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ViewCreateParams +import com.braintrustdata.api.models.ViewCreateParams.ViewCreateBody class ViewCreateParamsTest { @Test fun createViewCreateParams() { - 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() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(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() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) + .build() } @Test fun getBody() { - 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() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) - assertThat(body.viewType()).isEqualTo(ViewCreateParams.ViewType.PROJECTS) - assertThat(body.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.options()) - .isEqualTo( - ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()) - .isEqualTo( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .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() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewCreateParams.ObjectType.ORGANIZATION) + assertThat(body.viewType()).isEqualTo(ViewCreateParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.options()).isEqualTo(ViewOptions.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()).isEqualTo(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) } @Test fun getBodyWithoutOptionalFields() { - val params = - ViewCreateParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = ViewCreateParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt index f13af642..61b2483a 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataSearchTest.kt @@ -2,25 +2,31 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ViewDataSearch class ViewDataSearchTest { @Test fun createViewDataSearch() { - val viewDataSearch = - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - assertThat(viewDataSearch).isNotNull - assertThat(viewDataSearch.filter()).containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.match()).containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.sort()).containsExactly(JsonValue.from(mapOf())) - assertThat(viewDataSearch.tag()).containsExactly(JsonValue.from(mapOf())) + val viewDataSearch = ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build() + assertThat(viewDataSearch).isNotNull + assertThat(viewDataSearch.filter()).containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.match()).containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.sort()).containsExactly(JsonValue.from(mapOf())) + assertThat(viewDataSearch.tag()).containsExactly(JsonValue.from(mapOf())) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt index 4c142e0e..889f49d7 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDataTest.kt @@ -2,34 +2,35 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ViewData class ViewDataTest { @Test fun createViewData() { - val viewData = - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - assertThat(viewData).isNotNull - assertThat(viewData.search()) - .isEqualTo( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) + val viewData = ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build() + assertThat(viewData).isNotNull + assertThat(viewData.search()).isEqualTo(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt index 07e7efc1..6e80e319 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewDeleteParamsTest.kt @@ -2,58 +2,67 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ViewDeleteParams +import com.braintrustdata.api.models.ViewDeleteParams.ViewDeleteBody class ViewDeleteParamsTest { @Test fun createViewDeleteParams() { - 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 getBody() { - val params = - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) + val params = ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewDeleteParams.ObjectType.ORGANIZATION) } @Test fun getBodyWithoutOptionalFields() { - val params = - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun getPathParam() { - val params = - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .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") + .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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt index 6b53c944..2d9c9048 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewListParamsTest.kt @@ -2,60 +2,68 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ViewListParams class ViewListParamsTest { @Test fun createViewListParams() { - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .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(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewName("view_name") + .viewType(ViewListParams.ViewType.PROJECTS) + .build() } @Test fun getQueryParams() { - val params = - ViewListParams.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewListParams.ObjectType.ORGANIZATION) - .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .ids(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .limit(123L) - .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewName("view_name") - .viewType(ViewListParams.ViewType.PROJECTS) - .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(ViewListParams.ObjectType.ORGANIZATION.toString())) - expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put( - "ids", - listOf(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString()) - ) - expected.put("limit", listOf("123")) - expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("view_name", listOf("view_name")) - expected.put("view_type", listOf(ViewListParams.ViewType.PROJECTS.toString())) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewListParams.ObjectType.ORGANIZATION) + .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .ids(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .limit(123L) + .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewName("view_name") + .viewType(ViewListParams.ViewType.PROJECTS) + .build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("object_type", listOf(ViewListParams.ObjectType.ORGANIZATION.toString())) + expected.put("ending_before", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ids", listOf(ViewListParams.Ids.ofString("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").toString())) + expected.put("limit", listOf("123")) + expected.put("starting_after", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("view_name", listOf("view_name")) + expected.put("view_type", listOf(ViewListParams.ViewType.PROJECTS.toString())) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = - ViewListParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt index 8287a9b4..ea52d2c3 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewOptionsTest.kt @@ -2,23 +2,29 @@ package com.braintrustdata.api.models -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.ViewOptions class ViewOptionsTest { @Test fun createViewOptions() { - val viewOptions = - ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - assertThat(viewOptions).isNotNull - assertThat(viewOptions.columnOrder()).containsExactly("string") - assertThat(viewOptions.columnSizing()).isEqualTo(ViewOptions.ColumnSizing.builder().build()) - assertThat(viewOptions.columnVisibility()) - .isEqualTo(ViewOptions.ColumnVisibility.builder().build()) + val viewOptions = ViewOptions.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build() + assertThat(viewOptions).isNotNull + assertThat(viewOptions.columnOrder()).containsExactly("string") + assertThat(viewOptions.columnSizing()).isEqualTo(ViewOptions.ColumnSizing.builder().build()) + assertThat(viewOptions.columnVisibility()).isEqualTo(ViewOptions.ColumnVisibility.builder().build()) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt index c9fa17f3..b8ef75bc 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewReplaceParamsTest.kt @@ -2,116 +2,104 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.models.* +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ViewReplaceParams +import com.braintrustdata.api.models.ViewReplaceParams.ViewReplaceBody class ViewReplaceParamsTest { @Test fun createViewReplaceParams() { - 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() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(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() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) + .build() } @Test fun getBody() { - 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() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) - assertThat(body.viewType()).isEqualTo(ViewReplaceParams.ViewType.PROJECTS) - assertThat(body.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.options()) - .isEqualTo( - ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()) - .isEqualTo( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .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() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewReplaceParams.ObjectType.ORGANIZATION) + assertThat(body.viewType()).isEqualTo(ViewReplaceParams.ViewType.PROJECTS) + assertThat(body.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.options()).isEqualTo(ViewOptions.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()).isEqualTo(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) } @Test fun getBodyWithoutOptionalFields() { - val params = - ViewReplaceParams.builder() - .name("name") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("name") - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = ViewReplaceParams.builder() + .name("name") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.name()).isEqualTo("name") + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt index 9e08a8b6..4da081fb 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewRetrieveParamsTest.kt @@ -2,58 +2,66 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue +import com.braintrustdata.api.models.* +import com.braintrustdata.api.models.ViewRetrieveParams class ViewRetrieveParamsTest { @Test fun createViewRetrieveParams() { - 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 getQueryParams() { - val params = - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - expected.put("object_type", listOf(ViewRetrieveParams.ObjectType.ORGANIZATION.toString())) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("object_type", listOf(ViewRetrieveParams.ObjectType.ORGANIZATION.toString())) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getQueryParamsWithoutOptionalFields() { - val params = - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = mutableMapOf>() - expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - assertThat(params.getQueryParams()).isEqualTo(expected) + val params = ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("object_id", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) } @Test fun getPathParam() { - val params = - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .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") + .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-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt index a10700da..eb1e450c 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewTest.kt @@ -2,74 +2,65 @@ package com.braintrustdata.api.models -import com.braintrustdata.api.core.JsonValue +import java.time.LocalDate import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat +import java.time.format.DateTimeFormatter +import java.util.UUID import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.models.View 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() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(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()).isEqualTo(View.ViewType.PROJECTS) - assertThat(view.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(view.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(view.options()) - .isEqualTo( - ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - assertThat(view.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(view.viewData()) - .isEqualTo( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(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() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(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()).isEqualTo(View.ViewType.PROJECTS) + assertThat(view.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(view.deletedAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(view.options()).isEqualTo(ViewOptions.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + assertThat(view.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(view.viewData()).isEqualTo(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt index 7a5b58b0..1ba247c5 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/models/ViewUpdateParamsTest.kt @@ -2,127 +2,115 @@ package com.braintrustdata.api.models +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.UUID +import org.junit.jupiter.api.Test +import org.assertj.core.api.Assertions.assertThat +import org.apache.hc.core5.http.ContentType +import com.braintrustdata.api.core.ContentTypes +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.MultipartFormValue import com.braintrustdata.api.models.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test +import com.braintrustdata.api.models.ViewUpdateParams +import com.braintrustdata.api.models.ViewUpdateParams.ViewUpdateBody class ViewUpdateParamsTest { @Test fun createViewUpdateParams() { - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewUpdateParams.ObjectType.ORGANIZATION) - .name("name") - .options( - ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(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() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() } @Test fun getBody() { - 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() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) - assertThat(body.name()).isEqualTo("name") - assertThat(body.options()) - .isEqualTo( - ViewOptions.builder() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.viewData()) - .isEqualTo( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - assertThat(body.viewType()).isEqualTo(ViewUpdateParams.ViewType.PROJECTS) + 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() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.objectType()).isEqualTo(ViewUpdateParams.ObjectType.ORGANIZATION) + assertThat(body.name()).isEqualTo("name") + assertThat(body.options()).isEqualTo(ViewOptions.builder() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + assertThat(body.userId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.viewData()).isEqualTo(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) + assertThat(body.viewType()).isEqualTo(ViewUpdateParams.ViewType.PROJECTS) } @Test fun getBodyWithoutOptionalFields() { - val params = - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val params = ViewUpdateParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.objectId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun getPathParam() { - val params = - ViewUpdateParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .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") + .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-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt index 5f1e69c8..d520ac2e 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/ErrorHandlingTest.kt @@ -2,13 +2,44 @@ package com.braintrustdata.api.services +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.github.tomakehurst.wiremock.client.WireMock.binaryEqualTo +import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.get +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.put +import com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.delete +import com.github.tomakehurst.wiremock.client.WireMock.status +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy +import org.assertj.guava.api.Assertions.assertThat +import com.google.common.collect.ListMultimap +import com.google.common.collect.ImmutableListMultimap +import com.fasterxml.jackson.databind.json.JsonMapper +import java.io.IOException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.UUID +import org.assertj.core.api.InstanceOfAssertFactories +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import java.io.InputStream +import java.io.ByteArrayOutputStream import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.core.JsonNull import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue import com.braintrustdata.api.core.jsonMapper import com.braintrustdata.api.errors.BadRequestException import com.braintrustdata.api.errors.BraintrustError import com.braintrustdata.api.errors.BraintrustException +import com.braintrustdata.api.errors.BraintrustServiceException import com.braintrustdata.api.errors.InternalServerException import com.braintrustdata.api.errors.NotFoundException import com.braintrustdata.api.errors.PermissionDeniedException @@ -17,339 +48,255 @@ import com.braintrustdata.api.errors.UnauthorizedException import com.braintrustdata.api.errors.UnexpectedStatusCodeException import com.braintrustdata.api.errors.UnprocessableEntityException import com.braintrustdata.api.models.* -import com.fasterxml.jackson.databind.json.JsonMapper -import com.github.tomakehurst.wiremock.client.WireMock.anyUrl -import com.github.tomakehurst.wiremock.client.WireMock.get -import com.github.tomakehurst.wiremock.client.WireMock.ok -import com.github.tomakehurst.wiremock.client.WireMock.post -import com.github.tomakehurst.wiremock.client.WireMock.status -import com.github.tomakehurst.wiremock.client.WireMock.stubFor -import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo -import com.github.tomakehurst.wiremock.junit5.WireMockTest -import com.google.common.collect.ImmutableListMultimap -import com.google.common.collect.ListMultimap -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatThrownBy -import org.assertj.core.api.InstanceOfAssertFactories -import org.assertj.guava.api.Assertions.assertThat -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test +import com.braintrustdata.api.models.ProjectListPage +import com.braintrustdata.api.models.ProjectListParams @WireMockTest class ErrorHandlingTest { private val JSON_MAPPER: JsonMapper = jsonMapper() - private val BRAINTRUST_ERROR: BraintrustError = - BraintrustError.builder().putAdditionalProperty("key", JsonString.of("value")).build() + private val BRAINTRUST_ERROR: BraintrustError = BraintrustError.builder().putAdditionalProperty("key", JsonString.of("value")).build() private lateinit var client: BraintrustClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - client = - BraintrustOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) - .apiKey("My API Key") - .build() + client = BraintrustOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) + .apiKey("My API Key") + .build() } @Test fun projectsCreate200() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() - - val expected = - Project.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .settings(Project.Settings.builder().comparisonKey("comparison_key").build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - stubFor(post(anyUrl()).willReturn(ok().withBody(toJson(expected)))) - - assertThat(client.project().create(params)).isEqualTo(expected) + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() + + val expected = Project.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .settings(Project.Settings.builder() + .comparisonKey("comparison_key") + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + stubFor(post(anyUrl()) + .willReturn(ok().withBody(toJson(expected)))) + + assertThat(client.project().create(params)).isEqualTo(expected) } @Test fun projectsCreate400() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() - stubFor( - post(anyUrl()) - .willReturn(status(400).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) - ) + stubFor(post(anyUrl()) + .willReturn(status(400).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR)))) - assertThatThrownBy({ client.project().create(params) }) - .satisfies({ e -> - assertBadRequest(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) - }) + assertThatThrownBy({ client.project().create(params) }) + .satisfies({ e -> assertBadRequest(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) } @Test fun projectsCreate401() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() - stubFor( - post(anyUrl()) - .willReturn(status(401).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) - ) + stubFor(post(anyUrl()) + .willReturn(status(401).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR)))) - assertThatThrownBy({ client.project().create(params) }) - .satisfies({ e -> - assertUnauthorized(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) - }) + assertThatThrownBy({ client.project().create(params) }) + .satisfies({ e -> assertUnauthorized(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) } @Test fun projectsCreate403() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() - stubFor( - post(anyUrl()) - .willReturn(status(403).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) - ) + stubFor(post(anyUrl()) + .willReturn(status(403).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR)))) - assertThatThrownBy({ client.project().create(params) }) - .satisfies({ e -> - assertPermissionDenied(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) - }) + assertThatThrownBy({ client.project().create(params) }) + .satisfies({ e -> assertPermissionDenied(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) } @Test fun projectsCreate404() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() - stubFor( - post(anyUrl()) - .willReturn(status(404).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) - ) + stubFor(post(anyUrl()) + .willReturn(status(404).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR)))) - assertThatThrownBy({ client.project().create(params) }) - .satisfies({ e -> - assertNotFound(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) - }) + assertThatThrownBy({ client.project().create(params) }) + .satisfies({ e -> assertNotFound(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) } @Test fun projectsCreate422() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() - - stubFor( - post(anyUrl()) - .willReturn(status(422).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) - ) - - assertThatThrownBy({ client.project().create(params) }) - .satisfies({ e -> - assertUnprocessableEntity( - e, - ImmutableListMultimap.of("Foo", "Bar"), - BRAINTRUST_ERROR - ) - }) + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() + + stubFor(post(anyUrl()) + .willReturn(status(422).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR)))) + + assertThatThrownBy({ client.project().create(params) }) + .satisfies({ e -> assertUnprocessableEntity(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) } @Test fun projectsCreate429() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() - stubFor( - post(anyUrl()) - .willReturn(status(429).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) - ) + stubFor(post(anyUrl()) + .willReturn(status(429).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR)))) - assertThatThrownBy({ client.project().create(params) }) - .satisfies({ e -> - assertRateLimit(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) - }) + assertThatThrownBy({ client.project().create(params) }) + .satisfies({ e -> assertRateLimit(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) } @Test fun projectsCreate500() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() - stubFor( - post(anyUrl()) - .willReturn(status(500).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) - ) + stubFor(post(anyUrl()) + .willReturn(status(500).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR)))) - assertThatThrownBy({ client.project().create(params) }) - .satisfies({ e -> - assertInternalServer(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) - }) + assertThatThrownBy({ client.project().create(params) }) + .satisfies({ e -> assertInternalServer(e, ImmutableListMultimap.of("Foo", "Bar"), BRAINTRUST_ERROR) }) } @Test fun unexpectedStatusCode() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() - - stubFor( - post(anyUrl()) - .willReturn(status(999).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR))) - ) - - assertThatThrownBy({ client.project().create(params) }) - .satisfies({ e -> - assertUnexpectedStatusCodeException( - e, - 999, - ImmutableListMultimap.of("Foo", "Bar"), - toJson(BRAINTRUST_ERROR) - ) - }) + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() + + stubFor(post(anyUrl()) + .willReturn(status(999).withHeader("Foo", "Bar").withBody(toJson(BRAINTRUST_ERROR)))) + + assertThatThrownBy({ client.project().create(params) }).satisfies({ e -> assertUnexpectedStatusCodeException(e, 999, ImmutableListMultimap.of("Foo", "Bar"), toJson(BRAINTRUST_ERROR)) }) } @Test fun invalidBody() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() - stubFor(post(anyUrl()).willReturn(status(200).withBody("Not JSON"))) + stubFor(post(anyUrl()) + .willReturn(status(200).withBody("Not JSON"))) - assertThatThrownBy({ client.project().create(params) }) - .satisfies({ e -> - assertThat(e) - .isInstanceOf(BraintrustException::class.java) - .hasMessage("Error reading response") - }) + assertThatThrownBy({ client.project().create(params) }).satisfies({ e -> assertThat(e) + .isInstanceOf(BraintrustException::class.java) + .hasMessage("Error reading response") }) } @Test fun invalidErrorBody() { - val params = ProjectCreateParams.builder().name("name").orgName("org_name").build() + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build() - stubFor(post(anyUrl()).willReturn(status(400).withBody("Not JSON"))) + stubFor(post(anyUrl()) + .willReturn(status(400).withBody("Not JSON"))) - assertThatThrownBy({ client.project().create(params) }) - .satisfies({ e -> - assertBadRequest(e, ImmutableListMultimap.of(), BraintrustError.builder().build()) - }) + assertThatThrownBy({ client.project().create(params) }).satisfies({ e -> assertBadRequest(e, ImmutableListMultimap.of(), BraintrustError.builder().build()) }) } private fun toJson(body: T): ByteArray { - return JSON_MAPPER.writeValueAsBytes(body) + return JSON_MAPPER.writeValueAsBytes(body) } - private fun assertUnexpectedStatusCodeException( - throwable: Throwable, - statusCode: Int, - headers: ListMultimap, - responseBody: ByteArray - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnexpectedStatusCodeException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(statusCode) - assertThat(e.body()).isEqualTo(String(responseBody)) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) + private fun assertUnexpectedStatusCodeException(throwable: Throwable, statusCode: Int, headers: ListMultimap, responseBody: ByteArray) { + assertThat(throwable) + .asInstanceOf(InstanceOfAssertFactories.throwable(UnexpectedStatusCodeException::class.java)) + .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(statusCode) + assertThat(e.body()).isEqualTo(String(responseBody)) + assertThat(e.headers()).containsAllEntriesOf(headers) }) } - private fun assertBadRequest( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(BadRequestException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(400) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) + private fun assertBadRequest(throwable: Throwable, headers: ListMultimap, error: BraintrustError) { + assertThat(throwable) + .asInstanceOf(InstanceOfAssertFactories.throwable(BadRequestException::class.java)) + .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.error()).isEqualTo(error) + assertThat(e.headers()).containsAllEntriesOf(headers) }) } - private fun assertUnauthorized( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(UnauthorizedException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(401) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) + private fun assertUnauthorized(throwable: Throwable, headers: ListMultimap, error: BraintrustError) { + assertThat(throwable) + .asInstanceOf(InstanceOfAssertFactories.throwable(UnauthorizedException::class.java)) + .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.error()).isEqualTo(error) + assertThat(e.headers()).containsAllEntriesOf(headers) }) } - private fun assertPermissionDenied( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(PermissionDeniedException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(403) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) + private fun assertPermissionDenied(throwable: Throwable, headers: ListMultimap, error: BraintrustError) { + assertThat(throwable) + .asInstanceOf(InstanceOfAssertFactories.throwable(PermissionDeniedException::class.java)) + .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.error()).isEqualTo(error) + assertThat(e.headers()).containsAllEntriesOf(headers) }) } - private fun assertNotFound( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(NotFoundException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(404) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) + private fun assertNotFound(throwable: Throwable, headers: ListMultimap, error: BraintrustError) { + assertThat(throwable) + .asInstanceOf(InstanceOfAssertFactories.throwable(NotFoundException::class.java)) + .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.error()).isEqualTo(error) + assertThat(e.headers()).containsAllEntriesOf(headers) }) } - private fun assertUnprocessableEntity( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnprocessableEntityException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(422) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) + private fun assertUnprocessableEntity(throwable: Throwable, headers: ListMultimap, error: BraintrustError) { + assertThat(throwable) + .asInstanceOf(InstanceOfAssertFactories.throwable(UnprocessableEntityException::class.java)) + .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.error()).isEqualTo(error) + assertThat(e.headers()).containsAllEntriesOf(headers) }) } - private fun assertRateLimit( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(RateLimitException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(429) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) + private fun assertRateLimit(throwable: Throwable, headers: ListMultimap, error: BraintrustError) { + assertThat(throwable) + .asInstanceOf(InstanceOfAssertFactories.throwable(RateLimitException::class.java)) + .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.error()).isEqualTo(error) + assertThat(e.headers()).containsAllEntriesOf(headers) }) } - private fun assertInternalServer( - throwable: Throwable, - headers: ListMultimap, - error: BraintrustError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(InternalServerException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(500) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers()).containsAllEntriesOf(headers) - }) + private fun assertInternalServer(throwable: Throwable, headers: ListMultimap, error: BraintrustError) { + assertThat(throwable) + .asInstanceOf(InstanceOfAssertFactories.throwable(InternalServerException::class.java)) + .satisfies({ e -> assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.error()).isEqualTo(error) + assertThat(e.headers()).containsAllEntriesOf(headers) }) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt index 2d94aabc..e671fa40 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/ServiceParamsTest.kt @@ -2,28 +2,44 @@ package com.braintrustdata.api.services -import com.braintrustdata.api.client.BraintrustClient -import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.core.JsonString -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.core.jsonMapper -import com.braintrustdata.api.models.* import com.fasterxml.jackson.databind.json.JsonMapper -import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.client.WireMock.equalTo -import com.github.tomakehurst.wiremock.client.WireMock.get -import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.post -import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor import com.github.tomakehurst.wiremock.client.WireMock.put +import com.github.tomakehurst.wiremock.client.WireMock.delete +import com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath import com.github.tomakehurst.wiremock.client.WireMock.verify -import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo -import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor +import java.io.IOException +import java.time.LocalDate import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import com.braintrustdata.api.client.BraintrustClient +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.core.jsonMapper +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.errors.BraintrustError +import com.braintrustdata.api.errors.BraintrustInvalidDataException +import com.braintrustdata.api.errors.BraintrustServiceException +import com.braintrustdata.api.errors.UnexpectedStatusCodeException +import com.braintrustdata.api.models.ProjectListPage +import com.braintrustdata.api.models.ProjectListParams +import com.braintrustdata.api.models.* @WireMockTest class ServiceParamsTest { @@ -34,57 +50,54 @@ class ServiceParamsTest { @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - client = - BraintrustOkHttpClient.builder() - .apiKey("My API Key") - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) - .build() + client = BraintrustOkHttpClient.builder() + .apiKey("My API Key") + .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) + .build() } @Test fun projectsCreateWithAdditionalParams() { - val additionalHeaders = mutableMapOf>() + val additionalHeaders = mutableMapOf>() - additionalHeaders.put("x-test-header", listOf("abc1234")) + additionalHeaders.put("x-test-header", listOf("abc1234")) - val additionalQueryParams = mutableMapOf>() + val additionalQueryParams = mutableMapOf>() - additionalQueryParams.put("test_query_param", listOf("def567")) + additionalQueryParams.put("test_query_param", listOf("def567")) - val additionalBodyProperties = mutableMapOf() + val additionalBodyProperties = mutableMapOf() - additionalBodyProperties.put("testBodyProperty", JsonString.of("ghi890")) + additionalBodyProperties.put("testBodyProperty", JsonString.of("ghi890")) - val params = - ProjectCreateParams.builder() - .name("name") - .orgName("org_name") - .additionalHeaders(additionalHeaders) - .additionalBodyProperties(additionalBodyProperties) - .additionalQueryParams(additionalQueryParams) - .build() + val params = ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .additionalHeaders(additionalHeaders) + .additionalBodyProperties(additionalBodyProperties) + .additionalQueryParams(additionalQueryParams) + .build() - val apiResponse = - Project.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .settings(Project.Settings.builder().comparisonKey("comparison_key").build()) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + val apiResponse = Project.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .orgId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .settings(Project.Settings.builder() + .comparisonKey("comparison_key") + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() - stubFor( - post(anyUrl()) - .withHeader("x-test-header", equalTo("abc1234")) - .withQueryParam("test_query_param", equalTo("def567")) - .withRequestBody(matchingJsonPath("$.testBodyProperty", equalTo("ghi890"))) - .willReturn(ok(JSON_MAPPER.writeValueAsString(apiResponse))) - ) + stubFor(post(anyUrl()) + .withHeader("x-test-header", equalTo("abc1234")) + .withQueryParam("test_query_param", equalTo("def567")) + .withRequestBody(matchingJsonPath("$.testBodyProperty", equalTo("ghi890"))) + .willReturn(ok(JSON_MAPPER.writeValueAsString(apiResponse)))) - client.project().create(params) + client.project().create(params) - verify(postRequestedFor(anyUrl())) + verify(postRequestedFor(anyUrl())) } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt index 1f733e3f..af0548c6 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/AclServiceTest.kt @@ -2,85 +2,93 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.AclService +import com.braintrustdata.api.models.AclListPage import com.braintrustdata.api.models.AclListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class AclServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acl() - 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() - ) - println(acl) - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acl() + 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()) + println(acl) + acl.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acl() - val acl = - aclService.retrieve( - AclRetrieveParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - println(acl) - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acl() + val acl = aclService.retrieve(AclRetrieveParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(acl) + acl.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acl() - val response = - aclService.list( - AclListParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acl() + val response = aclService.list(AclListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val aclService = client.acl() - val acl = - aclService.delete( - AclDeleteParams.builder().aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - println(acl) - acl.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val aclService = client.acl() + val acl = aclService.delete(AclDeleteParams.builder() + .aclId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(acl) + acl.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceTest.kt index d060e563..b41c7cba 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyResourceServiceTest.kt @@ -2,78 +2,86 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.ApiKeyResourceService +import com.braintrustdata.api.models.ApiKeyResourceListPage import com.braintrustdata.api.models.ApiKeyResourceListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class ApiKeyResourceServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyResourceService = client.apiKeyResource() - val createApiKeyOutput = - apiKeyResourceService.create( - ApiKeyResourceCreateParams.builder().name("name").orgName("org_name").build() - ) - println(createApiKeyOutput) - createApiKeyOutput.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyResourceService = client.apiKeyResource() + val createApiKeyOutput = apiKeyResourceService.create(ApiKeyResourceCreateParams.builder() + .name("name") + .orgName("org_name") + .build()) + println(createApiKeyOutput) + createApiKeyOutput.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyResourceService = client.apiKeyResource() - val apiKey = - apiKeyResourceService.retrieve( - ApiKeyResourceRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(apiKey) - apiKey.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyResourceService = client.apiKeyResource() + val apiKey = apiKeyResourceService.retrieve(ApiKeyResourceRetrieveParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(apiKey) + apiKey.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyResourceService = client.apiKeyResource() - val response = apiKeyResourceService.list(ApiKeyResourceListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyResourceService = client.apiKeyResource() + val response = apiKeyResourceService.list(ApiKeyResourceListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyResourceService = client.apiKeyResource() - val apiKey = - apiKeyResourceService.delete( - ApiKeyResourceDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(apiKey) - apiKey.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyResourceService = client.apiKeyResource() + val apiKey = apiKeyResourceService.delete(ApiKeyResourceDeleteParams.builder() + .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(apiKey) + apiKey.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt deleted file mode 100755 index bef46629..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ApiKeyServiceTest.kt +++ /dev/null @@ -1,79 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.blocking - -import com.braintrustdata.api.TestServerExtension -import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* -import com.braintrustdata.api.models.ApiKeyListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -class ApiKeyServiceTest { - - @Test - fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() - val createApiKeyOutput = - apiKeyService.create( - ApiKeyCreateParams.builder().name("name").orgName("org_name").build() - ) - println(createApiKeyOutput) - createApiKeyOutput.validate() - } - - @Test - fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() - val apiKey = - apiKeyService.retrieve( - ApiKeyRetrieveParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(apiKey) - apiKey.validate() - } - - @Test - fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() - val response = apiKeyService.list(ApiKeyListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } - } - - @Test - fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val apiKeyService = client.apiKeys() - val apiKey = - apiKeyService.delete( - ApiKeyDeleteParams.builder() - .apiKeyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(apiKey) - apiKey.validate() - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt index ccc35c8f..1f7a6026 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/DatasetServiceTest.kt @@ -2,241 +2,206 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.DatasetService +import com.braintrustdata.api.models.DatasetListPage import com.braintrustdata.api.models.DatasetListParams -import java.time.OffsetDateTime -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class DatasetServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val dataset = - datasetService.create( - DatasetCreateParams.builder() - .name("name") - .description("description") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(dataset) - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.dataset() + val dataset = datasetService.create(DatasetCreateParams.builder() + .name("name") + .description("description") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(dataset) + dataset.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val dataset = - datasetService.retrieve( - DatasetRetrieveParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(dataset) - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.dataset() + val dataset = datasetService.retrieve(DatasetRetrieveParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(dataset) + dataset.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val dataset = - datasetService.update( - DatasetUpdateParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .metadata(DatasetUpdateParams.Metadata.builder().build()) - .name("name") - .build() - ) - println(dataset) - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.dataset() + val dataset = datasetService.update(DatasetUpdateParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .metadata(DatasetUpdateParams.Metadata.builder().build()) + .name("name") + .build()) + println(dataset) + dataset.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val response = datasetService.list(DatasetListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.dataset() + val response = datasetService.list(DatasetListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val dataset = - datasetService.delete( - DatasetDeleteParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(dataset) - dataset.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.dataset() + val dataset = datasetService.delete(DatasetDeleteParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(dataset) + dataset.validate() } @Test fun callFeedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val feedbackResponseSchema = - datasetService.feedback( - DatasetFeedbackParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackDatasetItem.builder() - .id("id") - .comment("comment") - .metadata(FeedbackDatasetItem.Metadata.builder().build()) - .source(FeedbackDatasetItem.Source.APP) - .build() - ) - ) - .build() - ) - println(feedbackResponseSchema) - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.dataset() + val feedbackResponseSchema = datasetService.feedback(DatasetFeedbackParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackDatasetItem.builder() + .id("id") + .comment("comment") + .metadata(FeedbackDatasetItem.Metadata.builder().build()) + .source(FeedbackDatasetItem.Source.APP) + .build())) + .build()) + println(feedbackResponseSchema) + feedbackResponseSchema.validate() } @Test fun callFetch() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val fetchDatasetEventsResponse = - datasetService.fetch( - DatasetFetchParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - println(fetchDatasetEventsResponse) - fetchDatasetEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.dataset() + val fetchDatasetEventsResponse = datasetService.fetch(DatasetFetchParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + println(fetchDatasetEventsResponse) + fetchDatasetEventsResponse.validate() } @Test fun callFetchPost() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val fetchDatasetEventsResponse = - datasetService.fetchPost( - DatasetFetchPostParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - println(fetchDatasetEventsResponse) - fetchDatasetEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.dataset() + val fetchDatasetEventsResponse = datasetService.fetchPost(DatasetFetchPostParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + println(fetchDatasetEventsResponse) + fetchDatasetEventsResponse.validate() } @Test fun callInsert() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val insertEventsResponse = - datasetService.insert( - DatasetInsertParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - DatasetInsertParams.Event.ofInsertDatasetEventReplace( - InsertDatasetEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata(InsertDatasetEventReplace.Metadata.builder().build()) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - ) - println(insertEventsResponse) - insertEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.dataset() + val insertEventsResponse = datasetService.insert(DatasetInsertParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(DatasetInsertParams.Event.ofInsertDatasetEventReplace(InsertDatasetEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertDatasetEventReplace.Metadata.builder().build()) + .tags(listOf("string")) + .build()))) + .build()) + println(insertEventsResponse) + insertEventsResponse.validate() } @Test fun callSummarize() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val datasetService = client.dataset() - val summarizeDatasetResponse = - datasetService.summarize( - DatasetSummarizeParams.builder() - .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeData(true) - .build() - ) - println(summarizeDatasetResponse) - summarizeDatasetResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val datasetService = client.dataset() + val summarizeDatasetResponse = datasetService.summarize(DatasetSummarizeParams.builder() + .datasetId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeData(true) + .build()) + println(summarizeDatasetResponse) + summarizeDatasetResponse.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt index 8bde414e..639908c6 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ExperimentServiceTest.kt @@ -2,310 +2,261 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.ExperimentService +import com.braintrustdata.api.models.ExperimentListPage import com.braintrustdata.api.models.ExperimentListParams -import java.time.OffsetDateTime -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class ExperimentServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - 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().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() - ) - println(experiment) - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiment() + 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().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()) + println(experiment) + experiment.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - val experiment = - experimentService.retrieve( - ExperimentRetrieveParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(experiment) - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiment() + val experiment = experimentService.retrieve(ExperimentRetrieveParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(experiment) + experiment.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - 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().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() - ) - println(experiment) - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiment() + 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().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()) + println(experiment) + experiment.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - val response = experimentService.list(ExperimentListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiment() + val response = experimentService.list(ExperimentListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - val experiment = - experimentService.delete( - ExperimentDeleteParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(experiment) - experiment.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiment() + val experiment = experimentService.delete(ExperimentDeleteParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(experiment) + experiment.validate() } @Test fun callFeedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - val feedbackResponseSchema = - experimentService.feedback( - ExperimentFeedbackParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackExperimentItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackExperimentItem.Metadata.builder().build()) - .scores(FeedbackExperimentItem.Scores.builder().build()) - .source(FeedbackExperimentItem.Source.APP) - .build() - ) - ) - .build() - ) - println(feedbackResponseSchema) - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiment() + val feedbackResponseSchema = experimentService.feedback(ExperimentFeedbackParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackExperimentItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackExperimentItem.Metadata.builder().build()) + .scores(FeedbackExperimentItem.Scores.builder().build()) + .source(FeedbackExperimentItem.Source.APP) + .build())) + .build()) + println(feedbackResponseSchema) + feedbackResponseSchema.validate() } @Test fun callFetch() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - val fetchExperimentEventsResponse = - experimentService.fetch( - ExperimentFetchParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - println(fetchExperimentEventsResponse) - fetchExperimentEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiment() + val fetchExperimentEventsResponse = experimentService.fetch(ExperimentFetchParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + println(fetchExperimentEventsResponse) + fetchExperimentEventsResponse.validate() } @Test fun callFetchPost() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - val fetchExperimentEventsResponse = - experimentService.fetchPost( - ExperimentFetchPostParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - println(fetchExperimentEventsResponse) - fetchExperimentEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiment() + val fetchExperimentEventsResponse = experimentService.fetchPost(ExperimentFetchPostParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + println(fetchExperimentEventsResponse) + fetchExperimentEventsResponse.validate() } @Test fun callInsert() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - val insertEventsResponse = - experimentService.insert( - ExperimentInsertParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ExperimentInsertParams.Event.ofInsertExperimentEventReplace( - InsertExperimentEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertExperimentEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .datasetRecordId("dataset_record_id") - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertExperimentEventReplace.Metadata.builder().build() - ) - .metrics( - InsertExperimentEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertExperimentEventReplace.Scores.builder().build()) - .spanAttributes( - InsertExperimentEventReplace.SpanAttributes.builder() - .name("name") - .type( - InsertExperimentEventReplace.SpanAttributes.Type.LLM - ) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - ) - println(insertEventsResponse) - insertEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiment() + val insertEventsResponse = experimentService.insert(ExperimentInsertParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(ExperimentInsertParams.Event.ofInsertExperimentEventReplace(InsertExperimentEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertExperimentEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .datasetRecordId("dataset_record_id") + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertExperimentEventReplace.Metadata.builder().build()) + .metrics(InsertExperimentEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertExperimentEventReplace.Scores.builder().build()) + .spanAttributes(InsertExperimentEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertExperimentEventReplace.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build()))) + .build()) + println(insertEventsResponse) + insertEventsResponse.validate() } @Test fun callSummarize() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val experimentService = client.experiment() - val summarizeExperimentResponse = - experimentService.summarize( - ExperimentSummarizeParams.builder() - .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .summarizeScores(true) - .build() - ) - println(summarizeExperimentResponse) - summarizeExperimentResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val experimentService = client.experiment() + val summarizeExperimentResponse = experimentService.summarize(ExperimentSummarizeParams.builder() + .experimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comparisonExperimentId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .summarizeScores(true) + .build()) + println(summarizeExperimentResponse) + summarizeExperimentResponse.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt index e05e9bb4..c0d34f5b 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/FunctionServiceTest.kt @@ -2,407 +2,250 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.FunctionService +import com.braintrustdata.api.models.FunctionListPage import com.braintrustdata.api.models.FunctionListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class FunctionServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.function() - val function = - functionService.create( - FunctionCreateParams.builder() - .functionData( - FunctionCreateParams.FunctionData.ofPrompt( - FunctionCreateParams.FunctionData.Prompt.builder() - .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(FunctionCreateParams.FunctionType.TASK) - .origin( - FunctionCreateParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params - .OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - ) - println(function) - function.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.function() + val function = functionService.create(FunctionCreateParams.builder() + .functionData(FunctionCreateParams.FunctionData.ofPrompt(FunctionCreateParams.FunctionData.Prompt.builder() + .type(FunctionCreateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(FunctionCreateParams.FunctionType.TASK) + .origin(FunctionCreateParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionCreateParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build()) + println(function) + function.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.function() - val function = - functionService.retrieve( - FunctionRetrieveParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(function) - function.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.function() + val function = functionService.retrieve(FunctionRetrieveParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(function) + function.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.function() - val function = - functionService.update( - FunctionUpdateParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .functionData( - FunctionUpdateParams.FunctionData.ofPrompt( - FunctionUpdateParams.FunctionData.Prompt.builder() - .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params - .OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - ) - println(function) - function.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.function() + val function = functionService.update(FunctionUpdateParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .functionData(FunctionUpdateParams.FunctionData.ofPrompt(FunctionUpdateParams.FunctionData.Prompt.builder() + .type(FunctionUpdateParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build()) + println(function) + function.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.function() - val response = functionService.list(FunctionListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.function() + val response = functionService.list(FunctionListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.function() - val function = - functionService.delete( - FunctionDeleteParams.builder() - .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(function) - function.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.function() + val function = functionService.delete(FunctionDeleteParams.builder() + .functionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(function) + function.validate() } @Test fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val functionService = client.function() - val function = - functionService.replace( - FunctionReplaceParams.builder() - .functionData( - FunctionReplaceParams.FunctionData.ofPrompt( - FunctionReplaceParams.FunctionData.Prompt.builder() - .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) - .build() - ) - ) - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(FunctionReplaceParams.FunctionType.TASK) - .origin( - FunctionReplaceParams.Origin.builder() - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) - .internal_(true) - .build() - ) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params - .OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - ) - println(function) - function.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val functionService = client.function() + val function = functionService.replace(FunctionReplaceParams.builder() + .functionData(FunctionReplaceParams.FunctionData.ofPrompt(FunctionReplaceParams.FunctionData.Prompt.builder() + .type(FunctionReplaceParams.FunctionData.Prompt.Type.PROMPT) + .build())) + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(FunctionReplaceParams.FunctionType.TASK) + .origin(FunctionReplaceParams.Origin.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(FunctionReplaceParams.Origin.ObjectType.ORGANIZATION) + .internal_(true) + .build()) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build()) + println(function) + function.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt index d3e0d322..33b75c8d 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/GroupServiceTest.kt @@ -2,128 +2,127 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.GroupService +import com.braintrustdata.api.models.GroupListPage import com.braintrustdata.api.models.GroupListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class GroupServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.group() - val group = - groupService.create( - GroupCreateParams.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - ) - println(group) - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.group() + val group = groupService.create(GroupCreateParams.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build()) + println(group) + group.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.group() - val group = - groupService.retrieve( - GroupRetrieveParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(group) - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.group() + val group = groupService.retrieve(GroupRetrieveParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(group) + group.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.group() - val group = - groupService.update( - GroupUpdateParams.builder() - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - ) - println(group) - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.group() + val group = groupService.update(GroupUpdateParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .removeMemberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build()) + println(group) + group.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.group() - val response = groupService.list(GroupListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.group() + val response = groupService.list(GroupListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.group() - val group = - groupService.delete( - GroupDeleteParams.builder().groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - println(group) - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.group() + val group = groupService.delete(GroupDeleteParams.builder() + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(group) + group.validate() } @Test fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val groupService = client.group() - val group = - groupService.replace( - GroupReplaceParams.builder() - .name("name") - .description("description") - .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - ) - println(group) - group.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val groupService = client.group() + val group = groupService.replace(GroupReplaceParams.builder() + .name("name") + .description("description") + .memberGroups(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .memberUsers(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build()) + println(group) + group.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrgSecretServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrgSecretServiceTest.kt index 186d77cc..00cafd45 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrgSecretServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrgSecretServiceTest.kt @@ -2,128 +2,125 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.OrgSecretService +import com.braintrustdata.api.models.OrgSecretListPage import com.braintrustdata.api.models.OrgSecretListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class OrgSecretServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val orgSecretService = client.orgSecret() - val orgSecret = - orgSecretService.create( - OrgSecretCreateParams.builder() - .name("name") - .metadata(OrgSecretCreateParams.Metadata.builder().build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - ) - println(orgSecret) - orgSecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val orgSecretService = client.orgSecret() + val orgSecret = orgSecretService.create(OrgSecretCreateParams.builder() + .name("name") + .metadata(OrgSecretCreateParams.Metadata.builder().build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build()) + println(orgSecret) + orgSecret.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val orgSecretService = client.orgSecret() - val orgSecret = - orgSecretService.retrieve( - OrgSecretRetrieveParams.builder() - .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(orgSecret) - orgSecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val orgSecretService = client.orgSecret() + val orgSecret = orgSecretService.retrieve(OrgSecretRetrieveParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(orgSecret) + orgSecret.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val orgSecretService = client.orgSecret() - val orgSecret = - orgSecretService.update( - OrgSecretUpdateParams.builder() - .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .metadata(OrgSecretUpdateParams.Metadata.builder().build()) - .name("name") - .secret("secret") - .type("type") - .build() - ) - println(orgSecret) - orgSecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val orgSecretService = client.orgSecret() + val orgSecret = orgSecretService.update(OrgSecretUpdateParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .metadata(OrgSecretUpdateParams.Metadata.builder().build()) + .name("name") + .secret("secret") + .type("type") + .build()) + println(orgSecret) + orgSecret.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val orgSecretService = client.orgSecret() - val response = orgSecretService.list(OrgSecretListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val orgSecretService = client.orgSecret() + val response = orgSecretService.list(OrgSecretListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val orgSecretService = client.orgSecret() - val orgSecret = - orgSecretService.delete( - OrgSecretDeleteParams.builder() - .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(orgSecret) - orgSecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val orgSecretService = client.orgSecret() + val orgSecret = orgSecretService.delete(OrgSecretDeleteParams.builder() + .orgSecretId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(orgSecret) + orgSecret.validate() } @Test fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val orgSecretService = client.orgSecret() - val orgSecret = - orgSecretService.replace( - OrgSecretReplaceParams.builder() - .name("name") - .metadata(OrgSecretReplaceParams.Metadata.builder().build()) - .orgName("org_name") - .secret("secret") - .type("type") - .build() - ) - println(orgSecret) - orgSecret.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val orgSecretService = client.orgSecret() + val orgSecret = orgSecretService.replace(OrgSecretReplaceParams.builder() + .name("name") + .metadata(OrgSecretReplaceParams.Metadata.builder().build()) + .orgName("org_name") + .secret("secret") + .type("type") + .build()) + println(orgSecret) + orgSecret.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt index fbc7b447..059bb4aa 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/OrganizationServiceTest.kt @@ -2,85 +2,90 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.OrganizationService +import com.braintrustdata.api.models.OrganizationListPage import com.braintrustdata.api.models.OrganizationListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class OrganizationServiceTest { @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organization() - val organization = - organizationService.retrieve( - OrganizationRetrieveParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(organization) - organization.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organization() + val organization = organizationService.retrieve(OrganizationRetrieveParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(organization) + organization.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organization() - 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() - ) - println(organization) - organization.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organization() + 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()) + println(organization) + organization.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organization() - val response = organizationService.list(OrganizationListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organization() + val response = organizationService.list(OrganizationListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val organizationService = client.organization() - val organization = - organizationService.delete( - OrganizationDeleteParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(organization) - organization.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val organizationService = client.organization() + val organization = organizationService.delete(OrganizationDeleteParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(organization) + organization.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt index 9139914c..54c0a65f 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectScoreServiceTest.kt @@ -2,140 +2,134 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.ProjectScoreService +import com.braintrustdata.api.models.ProjectScoreListPage import com.braintrustdata.api.models.ProjectScoreListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class ProjectScoreServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScore() - val projectScore = - projectScoreService.create( - ProjectScoreCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) - .categories( - ProjectScoreCreateParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .build() - ) - println(projectScore) - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScore() + val projectScore = projectScoreService.create(ProjectScoreCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreCreateParams.ScoreType.SLIDER) + .categories(ProjectScoreCreateParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + .description("description") + .build()) + println(projectScore) + projectScore.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScore() - val projectScore = - projectScoreService.retrieve( - ProjectScoreRetrieveParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(projectScore) - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScore() + val projectScore = projectScoreService.retrieve(ProjectScoreRetrieveParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(projectScore) + projectScore.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScore() - val projectScore = - projectScoreService.update( - ProjectScoreUpdateParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .categories( - ProjectScoreUpdateParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .name("name") - .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) - .build() - ) - println(projectScore) - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScore() + val projectScore = projectScoreService.update(ProjectScoreUpdateParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .categories(ProjectScoreUpdateParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + .description("description") + .name("name") + .scoreType(ProjectScoreUpdateParams.ScoreType.SLIDER) + .build()) + println(projectScore) + projectScore.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScore() - val response = projectScoreService.list(ProjectScoreListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScore() + val response = projectScoreService.list(ProjectScoreListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScore() - val projectScore = - projectScoreService.delete( - ProjectScoreDeleteParams.builder() - .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(projectScore) - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScore() + val projectScore = projectScoreService.delete(ProjectScoreDeleteParams.builder() + .projectScoreId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(projectScore) + projectScore.validate() } @Test fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectScoreService = client.projectScore() - val projectScore = - projectScoreService.replace( - ProjectScoreReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) - .categories( - ProjectScoreReplaceParams.Categories.ofList( - listOf(ProjectScoreCategory.builder().name("name").value(42.23).build()) - ) - ) - .description("description") - .build() - ) - println(projectScore) - projectScore.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectScoreService = client.projectScore() + val projectScore = projectScoreService.replace(ProjectScoreReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scoreType(ProjectScoreReplaceParams.ScoreType.SLIDER) + .categories(ProjectScoreReplaceParams.Categories.ofList(listOf(ProjectScoreCategory.builder() + .name("name") + .value(42.23) + .build()))) + .description("description") + .build()) + println(projectScore) + projectScore.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt index 5f8606eb..56835634 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectServiceTest.kt @@ -2,102 +2,104 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.ProjectService +import com.braintrustdata.api.models.ProjectListPage import com.braintrustdata.api.models.ProjectListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class ProjectServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.project() - val project = - projectService.create( - ProjectCreateParams.builder().name("name").orgName("org_name").build() - ) - println(project) - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.project() + val project = projectService.create(ProjectCreateParams.builder() + .name("name") + .orgName("org_name") + .build()) + println(project) + project.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.project() - val project = - projectService.retrieve( - ProjectRetrieveParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(project) - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.project() + val project = projectService.retrieve(ProjectRetrieveParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(project) + project.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.project() - val project = - projectService.update( - ProjectUpdateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .settings( - ProjectUpdateParams.Settings.builder() - .comparisonKey("comparison_key") - .build() - ) - .build() - ) - println(project) - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.project() + val project = projectService.update(ProjectUpdateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .settings(ProjectUpdateParams.Settings.builder() + .comparisonKey("comparison_key") + .build()) + .build()) + println(project) + project.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.project() - val response = projectService.list(ProjectListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.project() + val response = projectService.list(ProjectListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectService = client.project() - val project = - projectService.delete( - ProjectDeleteParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(project) - project.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.project() + val project = projectService.delete(ProjectDeleteParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(project) + project.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt index 4bfae100..501f047d 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ProjectTagServiceTest.kt @@ -2,125 +2,122 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.ProjectTagService +import com.braintrustdata.api.models.ProjectTagListPage import com.braintrustdata.api.models.ProjectTagListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class ProjectTagServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTag() - val projectTag = - projectTagService.create( - ProjectTagCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - ) - println(projectTag) - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTag() + val projectTag = projectTagService.create(ProjectTagCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build()) + println(projectTag) + projectTag.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTag() - val projectTag = - projectTagService.retrieve( - ProjectTagRetrieveParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(projectTag) - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTag() + val projectTag = projectTagService.retrieve(ProjectTagRetrieveParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(projectTag) + projectTag.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTag() - val projectTag = - projectTagService.update( - ProjectTagUpdateParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .name("name") - .build() - ) - println(projectTag) - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTag() + val projectTag = projectTagService.update(ProjectTagUpdateParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .name("name") + .build()) + println(projectTag) + projectTag.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTag() - val response = projectTagService.list(ProjectTagListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTag() + val response = projectTagService.list(ProjectTagListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTag() - val projectTag = - projectTagService.delete( - ProjectTagDeleteParams.builder() - .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(projectTag) - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTag() + val projectTag = projectTagService.delete(ProjectTagDeleteParams.builder() + .projectTagId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(projectTag) + projectTag.validate() } @Test fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val projectTagService = client.projectTag() - val projectTag = - projectTagService.replace( - ProjectTagReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .color("color") - .description("description") - .build() - ) - println(projectTag) - projectTag.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectTagService = client.projectTag() + val projectTag = projectTagService.replace(ProjectTagReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .color("color") + .description("description") + .build()) + println(projectTag) + projectTag.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt index c852964a..5aaf5c04 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/PromptServiceTest.kt @@ -2,373 +2,232 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.PromptService +import com.braintrustdata.api.models.PromptListPage import com.braintrustdata.api.models.PromptListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class PromptServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompt() - val prompt = - promptService.create( - PromptCreateParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(PromptCreateParams.FunctionType.TASK) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params - .OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - ) - println(prompt) - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompt() + val prompt = promptService.create(PromptCreateParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(PromptCreateParams.FunctionType.TASK) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build()) + println(prompt) + prompt.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompt() - val prompt = - promptService.retrieve( - PromptRetrieveParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(prompt) - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompt() + val prompt = promptService.retrieve(PromptRetrieveParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(prompt) + prompt.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompt() - val prompt = - promptService.update( - PromptUpdateParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("description") - .name("name") - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params - .OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .slug("slug") - .tags(listOf("string")) - .build() - ) - println(prompt) - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompt() + val prompt = promptService.update(PromptUpdateParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("description") + .name("name") + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .slug("slug") + .tags(listOf("string")) + .build()) + println(prompt) + prompt.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompt() - val response = promptService.list(PromptListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompt() + val response = promptService.list(PromptListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompt() - val prompt = - promptService.delete( - PromptDeleteParams.builder() - .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - println(prompt) - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompt() + val prompt = promptService.delete(PromptDeleteParams.builder() + .promptId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(prompt) + prompt.validate() } @Test fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val promptService = client.prompt() - val prompt = - promptService.replace( - PromptReplaceParams.builder() - .name("name") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .description("description") - .functionType(PromptReplaceParams.FunctionType.TASK) - .promptData( - PromptData.builder() - .options( - PromptData.Options.builder() - .model("model") - .params( - PromptData.Options.Params.ofOpenAIModelParams( - PromptData.Options.Params.OpenAIModelParams.builder() - .frequencyPenalty(42.23) - .functionCall( - PromptData.Options.Params.OpenAIModelParams - .FunctionCall - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .FunctionCall - .Auto - .AUTO - ) - ) - .maxTokens(42.23) - .n(42.23) - .presencePenalty(42.23) - .responseFormat( - PromptData.Options.Params.OpenAIModelParams - .ResponseFormat - .builder() - .type( - PromptData.Options.Params - .OpenAIModelParams - .ResponseFormat - .Type - .JSON_OBJECT - ) - .build() - ) - .stop(listOf("string")) - .temperature(42.23) - .toolChoice( - PromptData.Options.Params.OpenAIModelParams - .ToolChoice - .ofAuto( - PromptData.Options.Params - .OpenAIModelParams - .ToolChoice - .Auto - .AUTO - ) - ) - .topP(42.23) - .useCache(true) - .build() - ) - ) - .position("position") - .build() - ) - .origin( - PromptData.Origin.builder() - .projectId("project_id") - .promptId("prompt_id") - .promptVersion("prompt_version") - .build() - ) - .parser( - PromptData.Parser.builder() - .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) - .type(PromptData.Parser.Type.LLM_CLASSIFIER) - .useCot(true) - .build() - ) - .prompt( - PromptData.Prompt.ofCompletion( - PromptData.Prompt.Completion.builder() - .content("content") - .type(PromptData.Prompt.Completion.Type.COMPLETION) - .build() - ) - ) - .build() - ) - .tags(listOf("string")) - .build() - ) - println(prompt) - prompt.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val promptService = client.prompt() + val prompt = promptService.replace(PromptReplaceParams.builder() + .name("name") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .description("description") + .functionType(PromptReplaceParams.FunctionType.TASK) + .promptData(PromptData.builder() + .options(PromptData.Options.builder() + .model("model") + .params(PromptData.Options.Params.ofOpenAIModelParams(PromptData.Options.Params.OpenAIModelParams.builder() + .frequencyPenalty(42.23) + .functionCall(PromptData.Options.Params.OpenAIModelParams.FunctionCall.ofAuto(PromptData.Options.Params.OpenAIModelParams.FunctionCall.Auto.AUTO)) + .maxTokens(42.23) + .n(42.23) + .presencePenalty(42.23) + .responseFormat(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.builder() + .type(PromptData.Options.Params.OpenAIModelParams.ResponseFormat.Type.JSON_OBJECT) + .build()) + .stop(listOf("string")) + .temperature(42.23) + .toolChoice(PromptData.Options.Params.OpenAIModelParams.ToolChoice.ofAuto(PromptData.Options.Params.OpenAIModelParams.ToolChoice.Auto.AUTO)) + .topP(42.23) + .useCache(true) + .build())) + .position("position") + .build()) + .origin(PromptData.Origin.builder() + .projectId("project_id") + .promptId("prompt_id") + .promptVersion("prompt_version") + .build()) + .parser(PromptData.Parser.builder() + .choiceScores(PromptData.Parser.ChoiceScores.builder().build()) + .type(PromptData.Parser.Type.LLM_CLASSIFIER) + .useCot(true) + .build()) + .prompt(PromptData.Prompt.ofCompletion(PromptData.Prompt.Completion.builder() + .content("content") + .type(PromptData.Prompt.Completion.Type.COMPLETION) + .build())) + .build()) + .tags(listOf("string")) + .build()) + println(prompt) + prompt.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt index 72b81e0a..2cafed52 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/RoleServiceTest.kt @@ -2,168 +2,139 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.RoleService +import com.braintrustdata.api.models.RoleListPage import com.braintrustdata.api.models.RoleListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class RoleServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.role() - val role = - roleService.create( - RoleCreateParams.builder() - .name("name") - .description("description") - .memberPermissions( - listOf( - RoleCreateParams.MemberPermission.builder() - .permission(RoleCreateParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleCreateParams.MemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) - ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - ) - println(role) - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.role() + val role = roleService.create(RoleCreateParams.builder() + .name("name") + .description("description") + .memberPermissions(listOf(RoleCreateParams.MemberPermission.builder() + .permission(RoleCreateParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleCreateParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build()) + println(role) + role.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.role() - val role = - roleService.retrieve( - RoleRetrieveParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - println(role) - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.role() + val role = roleService.retrieve(RoleRetrieveParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(role) + role.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.role() - val role = - roleService.update( - RoleUpdateParams.builder() - .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addMemberPermissions( - listOf( - RoleUpdateParams.AddMemberPermission.builder() - .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) - .restrictObjectType( - RoleUpdateParams.AddMemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) - ) - .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .description("description") - .name("name") - .removeMemberPermissions( - listOf( - RoleUpdateParams.RemoveMemberPermission.builder() - .permission( - RoleUpdateParams.RemoveMemberPermission.Permission.CREATE - ) - .restrictObjectType( - RoleUpdateParams.RemoveMemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) - ) - .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - ) - println(role) - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.role() + val role = roleService.update(RoleUpdateParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addMemberPermissions(listOf(RoleUpdateParams.AddMemberPermission.builder() + .permission(RoleUpdateParams.AddMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.AddMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .addMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .description("description") + .name("name") + .removeMemberPermissions(listOf(RoleUpdateParams.RemoveMemberPermission.builder() + .permission(RoleUpdateParams.RemoveMemberPermission.Permission.CREATE) + .restrictObjectType(RoleUpdateParams.RemoveMemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .removeMemberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build()) + println(role) + role.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.role() - val response = roleService.list(RoleListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.role() + val response = roleService.list(RoleListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.role() - val role = - roleService.delete( - RoleDeleteParams.builder().roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - println(role) - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.role() + val role = roleService.delete(RoleDeleteParams.builder() + .roleId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(role) + role.validate() } @Test fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val roleService = client.role() - val role = - roleService.replace( - RoleReplaceParams.builder() - .name("name") - .description("description") - .memberPermissions( - listOf( - RoleReplaceParams.MemberPermission.builder() - .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) - .restrictObjectType( - RoleReplaceParams.MemberPermission.RestrictObjectType - .ORGANIZATION - ) - .build() - ) - ) - .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .orgName("org_name") - .build() - ) - println(role) - role.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val roleService = client.role() + val role = roleService.replace(RoleReplaceParams.builder() + .name("name") + .description("description") + .memberPermissions(listOf(RoleReplaceParams.MemberPermission.builder() + .permission(RoleReplaceParams.MemberPermission.Permission.CREATE) + .restrictObjectType(RoleReplaceParams.MemberPermission.RestrictObjectType.ORGANIZATION) + .build())) + .memberRoles(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .orgName("org_name") + .build()) + println(role) + role.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt index ab277bdc..c4bdf5ae 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/TopLevelServiceTest.kt @@ -2,27 +2,39 @@ package com.braintrustdata.api.services.blocking -import com.braintrustdata.api.TestServerExtension -import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach +import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient +import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.TopLevelService +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class TopLevelServiceTest { @Test fun callHelloWorld() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val topLevelService = client.topLevel() - val topLevelHelloWorldResponse = - topLevelService.helloWorld(TopLevelHelloWorldParams.builder().build()) - println(topLevelHelloWorldResponse) - assertThat(topLevelHelloWorldResponse).isNotBlank() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val topLevelService = client.topLevel() + val topLevelHelloWorldResponse = topLevelService.helloWorld(TopLevelHelloWorldParams.builder().build()) + println(topLevelHelloWorldResponse) + assertThat(topLevelHelloWorldResponse).isNotBlank() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt index 747c114a..b02c3ea1 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/UserServiceTest.kt @@ -2,42 +2,57 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.UserService +import com.braintrustdata.api.models.UserListPage import com.braintrustdata.api.models.UserListParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class UserServiceTest { @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userService = client.user() - val user = - userService.retrieve( - UserRetrieveParams.builder().userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - println(user) - user.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userService = client.user() + val user = userService.retrieve(UserRetrieveParams.builder() + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(user) + user.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val userService = client.user() - val response = userService.list(UserListParams.builder().build()) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val userService = client.user() + val response = userService.list(UserListParams.builder().build()) + println(response) + response.objects().forEach { + it.validate() + } } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt index adfd296d..c03a6b66 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/ViewServiceTest.kt @@ -2,197 +2,173 @@ package com.braintrustdata.api.services.blocking +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.models.* +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.ViewService +import com.braintrustdata.api.models.ViewListPage import com.braintrustdata.api.models.ViewListParams -import java.time.OffsetDateTime -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith +import com.braintrustdata.api.models.* @ExtendWith(TestServerExtension::class) class ViewServiceTest { @Test fun callCreate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.view() - 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() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - .build() - ) - println(view) - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.view() + 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() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) + .build()) + println(view) + view.validate() } @Test fun callRetrieve() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.view() - val view = - viewService.retrieve( - ViewRetrieveParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) - .build() - ) - println(view) - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.view() + val view = viewService.retrieve(ViewRetrieveParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewRetrieveParams.ObjectType.ORGANIZATION) + .build()) + println(view) + view.validate() } @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.view() - 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() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - .viewType(ViewUpdateParams.ViewType.PROJECTS) - .build() - ) - println(view) - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.view() + 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() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) + .viewType(ViewUpdateParams.ViewType.PROJECTS) + .build()) + println(view) + view.validate() } @Test fun callList() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.view() - val response = - viewService.list( - ViewListParams.builder().objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - println(response) - response.objects().forEach { it.validate() } + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.view() + val response = viewService.list(ViewListParams.builder() + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build()) + println(response) + response.objects().forEach { + it.validate() + } } @Test fun callDelete() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.view() - val view = - viewService.delete( - ViewDeleteParams.builder() - .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) - .build() - ) - println(view) - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.view() + val view = viewService.delete(ViewDeleteParams.builder() + .viewId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .objectType(ViewDeleteParams.ObjectType.ORGANIZATION) + .build()) + println(view) + view.validate() } @Test fun callReplace() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val viewService = client.view() - 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() - .columnOrder(listOf("string")) - .columnSizing(ViewOptions.ColumnSizing.builder().build()) - .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) - .build() - ) - .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .viewData( - ViewData.builder() - .search( - ViewDataSearch.builder() - .filter(listOf(JsonValue.from(mapOf()))) - .match(listOf(JsonValue.from(mapOf()))) - .sort(listOf(JsonValue.from(mapOf()))) - .tag(listOf(JsonValue.from(mapOf()))) - .build() - ) - .build() - ) - .build() - ) - println(view) - view.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val viewService = client.view() + 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() + .columnOrder(listOf("string")) + .columnSizing(ViewOptions.ColumnSizing.builder().build()) + .columnVisibility(ViewOptions.ColumnVisibility.builder().build()) + .build()) + .userId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .viewData(ViewData.builder() + .search(ViewDataSearch.builder() + .filter(listOf(JsonValue.from(mapOf()))) + .match(listOf(JsonValue.from(mapOf()))) + .sort(listOf(JsonValue.from(mapOf()))) + .tag(listOf(JsonValue.from(mapOf()))) + .build()) + .build()) + .build()) + println(view) + view.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceTest.kt index e85299cb..5f452c8b 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organization/MemberServiceTest.kt @@ -2,48 +2,55 @@ package com.braintrustdata.api.services.blocking.organization +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString +import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.organization.MemberService import com.braintrustdata.api.models.* -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) class MemberServiceTest { @Test fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val memberService = client.organization().members() - val organizationMemberUpdateResponse = - memberService.update( - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .emails(listOf("string")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .groupName("group_name") - .groupNames(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - ) - .build() - ) - println(organizationMemberUpdateResponse) - organizationMemberUpdateResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val memberService = client.organization().members() + val organizationMemberUpdateResponse = memberService.update(OrganizationMemberUpdateParams.builder() + .inviteUsers(OrganizationMemberUpdateParams.InviteUsers.builder() + .emails(listOf("string")) + .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .groupIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .groupName("group_name") + .groupNames(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .sendInviteEmails(true) + .build()) + .orgId("org_id") + .orgName("org_name") + .removeUsers(OrganizationMemberUpdateParams.RemoveUsers.builder() + .emails(listOf("string")) + .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build()) + .build()) + println(organizationMemberUpdateResponse) + organizationMemberUpdateResponse.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt deleted file mode 100755 index da1637aa..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/organizations/MemberServiceTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.blocking.organizations - -import com.braintrustdata.api.TestServerExtension -import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.models.* -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -class MemberServiceTest { - - @Test - fun callUpdate() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val memberService = client.organizations().members() - val organizationMemberUpdateResponse = - memberService.update( - OrganizationMemberUpdateParams.builder() - .inviteUsers( - OrganizationMemberUpdateParams.InviteUsers.builder() - .emails(listOf("string")) - .groupId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .groupName("group_name") - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .sendInviteEmails(true) - .build() - ) - .orgId("org_id") - .orgName("org_name") - .removeUsers( - OrganizationMemberUpdateParams.RemoveUsers.builder() - .emails(listOf("string")) - .ids(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) - .build() - ) - .build() - ) - println(organizationMemberUpdateResponse) - organizationMemberUpdateResponse.validate() - } -} diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceTest.kt index d04dcc58..b0328a70 100755 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceTest.kt +++ b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/project/LogServiceTest.kt @@ -2,163 +2,135 @@ package com.braintrustdata.api.services.blocking.project +import java.time.LocalDate +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Base64 +import java.util.Optional +import java.util.UUID +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.extension.ExtendWith +import org.junit.jupiter.api.BeforeEach import com.braintrustdata.api.TestServerExtension +import com.braintrustdata.api.client.BraintrustClient import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient +import com.braintrustdata.api.core.JsonNull +import com.braintrustdata.api.core.JsonString import com.braintrustdata.api.core.JsonValue +import com.braintrustdata.api.core.http.BinaryResponseContent +import com.braintrustdata.api.services.blocking.project.LogService import com.braintrustdata.api.models.* -import java.time.OffsetDateTime -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) class LogServiceTest { @Test fun callFeedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.project().logs() - val feedbackResponseSchema = - logService.feedback( - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .build() - ) - ) - .build() - ) - println(feedbackResponseSchema) - feedbackResponseSchema.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.project().logs() + val feedbackResponseSchema = logService.feedback(ProjectLogFeedbackParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .feedback(listOf(FeedbackProjectLogsItem.builder() + .id("id") + .comment("comment") + .expected(JsonValue.from(mapOf())) + .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) + .scores(FeedbackProjectLogsItem.Scores.builder().build()) + .source(FeedbackProjectLogsItem.Source.APP) + .build())) + .build()) + println(feedbackResponseSchema) + feedbackResponseSchema.validate() } @Test fun callFetch() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.project().logs() - val fetchProjectLogsEventsResponse = - logService.fetch( - ProjectLogFetchParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - println(fetchProjectLogsEventsResponse) - fetchProjectLogsEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.project().logs() + val fetchProjectLogsEventsResponse = logService.fetch(ProjectLogFetchParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + println(fetchProjectLogsEventsResponse) + fetchProjectLogsEventsResponse.validate() } @Test fun callFetchPost() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.project().logs() - val fetchProjectLogsEventsResponse = - logService.fetchPost( - ProjectLogFetchPostParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cursor("cursor") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - println(fetchProjectLogsEventsResponse) - fetchProjectLogsEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.project().logs() + val fetchProjectLogsEventsResponse = logService.fetchPost(ProjectLogFetchPostParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cursor("cursor") + .filters(listOf(PathLookupFilter.builder() + .path(listOf("string")) + .type(PathLookupFilter.Type.PATH_LOOKUP) + .value(JsonValue.from(mapOf())) + .build())) + .limit(123L) + .maxRootSpanId("max_root_span_id") + .maxXactId("max_xact_id") + .version("version") + .build()) + println(fetchProjectLogsEventsResponse) + fetchProjectLogsEventsResponse.validate() } @Test fun callInsert() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.project().logs() - val insertEventsResponse = - logService.insert( - ProjectLogInsertParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .events( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEventReplace.Metadata.builder().build() - ) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type( - InsertProjectLogsEventReplace.SpanAttributes.Type - .LLM - ) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - ) - println(insertEventsResponse) - insertEventsResponse.validate() + val client = BraintrustOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.project().logs() + val insertEventsResponse = logService.insert(ProjectLogInsertParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .events(listOf(ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace(InsertProjectLogsEventReplace.builder() + .id("id") + ._isMerge(true) + ._objectDelete(true) + ._parentId("_parent_id") + .context(InsertProjectLogsEventReplace.Context.builder() + .callerFilename("caller_filename") + .callerFunctionname("caller_functionname") + .callerLineno(123L) + .build()) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .error(JsonValue.from(mapOf())) + .expected(JsonValue.from(mapOf())) + .input(JsonValue.from(mapOf())) + .metadata(InsertProjectLogsEventReplace.Metadata.builder().build()) + .metrics(InsertProjectLogsEventReplace.Metrics.builder() + .completionTokens(123L) + .end(42.23) + .promptTokens(123L) + .start(42.23) + .tokens(123L) + .build()) + .output(JsonValue.from(mapOf())) + .scores(InsertProjectLogsEventReplace.Scores.builder().build()) + .spanAttributes(InsertProjectLogsEventReplace.SpanAttributes.builder() + .name("name") + .type(InsertProjectLogsEventReplace.SpanAttributes.Type.LLM) + .build()) + .tags(listOf("string")) + .build()))) + .build()) + println(insertEventsResponse) + insertEventsResponse.validate() } } diff --git a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt b/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt deleted file mode 100755 index a3373b04..00000000 --- a/braintrust-kotlin-core/src/test/kotlin/com/braintrustdata/api/services/blocking/projects/LogServiceTest.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.braintrustdata.api.services.blocking.projects - -import com.braintrustdata.api.TestServerExtension -import com.braintrustdata.api.client.okhttp.BraintrustOkHttpClient -import com.braintrustdata.api.core.JsonValue -import com.braintrustdata.api.models.* -import java.time.OffsetDateTime -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -class LogServiceTest { - - @Test - fun callFeedback() { - val client = - BraintrustOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val logService = client.projects().logs() - logService.feedback( - ProjectLogFeedbackParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .feedback( - listOf( - FeedbackProjectLogsItem.builder() - .id("id") - .comment("comment") - .expected(JsonValue.from(mapOf())) - .metadata(FeedbackProjectLogsItem.Metadata.builder().build()) - .scores(FeedbackProjectLogsItem.Scores.builder().build()) - .source(FeedbackProjectLogsItem.Source.APP) - .build() - ) - ) - .build() - ) - } - - @Test - fun callFetch() { - 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(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - println(fetchProjectLogsEventsResponse) - fetchProjectLogsEventsResponse.validate() - } - - @Test - fun callFetchPost() { - 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") - .filters( - listOf( - PathLookupFilter.builder() - .path(listOf("string")) - .type(PathLookupFilter.Type.PATH_LOOKUP) - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .limit(123L) - .maxRootSpanId("max_root_span_id") - .maxXactId("max_xact_id") - .version("version") - .build() - ) - println(fetchProjectLogsEventsResponse) - fetchProjectLogsEventsResponse.validate() - } - - @Test - fun callInsert() { - 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") - .events( - listOf( - ProjectLogInsertParams.Event.ofInsertProjectLogsEventReplace( - InsertProjectLogsEventReplace.builder() - .id("id") - ._isMerge(true) - ._objectDelete(true) - ._parentId("_parent_id") - .context( - InsertProjectLogsEventReplace.Context.builder() - .callerFilename("caller_filename") - .callerFunctionname("caller_functionname") - .callerLineno(123L) - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .error(JsonValue.from(mapOf())) - .expected(JsonValue.from(mapOf())) - .input(JsonValue.from(mapOf())) - .metadata( - InsertProjectLogsEventReplace.Metadata.builder().build() - ) - .metrics( - InsertProjectLogsEventReplace.Metrics.builder() - .completionTokens(123L) - .end(42.23) - .promptTokens(123L) - .start(42.23) - .tokens(123L) - .build() - ) - .output(JsonValue.from(mapOf())) - .scores(InsertProjectLogsEventReplace.Scores.builder().build()) - .spanAttributes( - InsertProjectLogsEventReplace.SpanAttributes.builder() - .name("name") - .type( - InsertProjectLogsEventReplace.SpanAttributes.Type - .LLM - ) - .build() - ) - .tags(listOf("string")) - .build() - ) - ) - ) - .build() - ) - println(insertEventsResponse) - insertEventsResponse.validate() - } -} diff --git a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts index 699828df..ab89109f 100755 --- a/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/braintrust.publish.gradle.kts @@ -28,7 +28,7 @@ configure { developers { developer { name.set("Braintrust") - email.set("infotest@braintrustdata.com") + email.set("info@braintrustdata.com") } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar old mode 100755 new mode 100644